Перейти к основному содержанию

Запуск: −50% на 3 месяца с кодом LANSARE50

Цены →

Google Sheets

Что работает сегодня; встроенная интеграция скоро.

  • Экспорт CSV или XLSX со страницы ответов, затем «Файл → Импорт» в Google Sheets.
  • Вебхуки через Zapier или Make (руководства выше).
  • Встроенная интеграция mform → Sheets: скоро.
  • Apps Script с опросом каждые 5 минут, ключ в Script properties (никогда в коде):
function pullMformResponses() {
  const props = PropertiesService.getScriptProperties();
  const key = props.getProperty("MFORM_API_KEY");
  const since = props.getProperty("LAST_COMPLETED_AT") || new Date(Date.now() - 864e5).toISOString();
  const base = "https://mform.md/api/public/v1/responses?status=completed&include=answers&limit=100" +
    "&form_id=" + props.getProperty("FORM_ID") + "&completed_after=" + encodeURIComponent(since);
  let rows = [], cursor = null;
  do { // newest first: read every page, then write oldest first
    const res = UrlFetchApp.fetch(base + (cursor ? "&cursor=" + encodeURIComponent(cursor) : ""),
      { headers: { Authorization: "Bearer " + key }, muteHttpExceptions: true });
    if (res.getResponseCode() !== 200) throw new Error(res.getContentText());
    const page = JSON.parse(res.getContentText());
    rows = rows.concat(page.data);
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
  rows.reverse();
  const sheet = SpreadsheetApp.getActiveSheet();
  rows.forEach((r) => sheet.appendRow([r.id, r.completed_at, JSON.stringify(r.fields)]));
  if (rows.length) props.setProperty("LAST_COMPLETED_AT", rows[rows.length - 1].completed_at);
}