Stop re-reading the whole sheet: a push‑sync design for Google Sheets and n8n
Описание и применение
Дизайн, где Google Sheets отправляет изменённые строки в n8n через webhook, а n8n обновляет данные, устраняет необходимость полной загрузки таблицы и обеспечивает синхронизацию с ночным реконсилированием.
Задача
A cron workflow that reads a Google Sheet on every run pays the same tax every time: the full download.
Результат
The design eliminates full‑sheet downloads, reduces latency, and maintains data consistency between Google Sheets and n8n.
Рабочий процесс
- 1. In Google Sheets, add an Apps Script function onEditPush that POSTs edited row data to an n8n webhook.
- 2. Create an installable trigger (From spreadsheet → On edit) to run the script.
- 3. In n8n, set up a Webhook node to receive POSTs and a Code node to zip values with headers and upsert into workflow static data keyed on appointment_id.
- 4. Handle invalid payloads by logging errors and responding 422.
- 5. Run a nightly job that queries the key column via the gviz/tq endpoint, flattens the result, and reconciles drift with the stored data.
Доказательства
A cron workflow that reads a Google Sheet on every run pays the same tax every time: the full download.
The sheet pushes edited rows
The upsert is idempotent. Two rapid edits to the same row fire two POSTs, the second overwrites the first, and that matches the sheet's own last-write-wins editing behavior.
- Дата записи: 2026-10-22T06:11:05.938Z