<aside> 📌

Workflow ID: pStGJY9nBWvTz-cVsJXha · instance: n8n.prhomelab.com · trigger: every 30 minutes · tag: DEV

</aside>

What it does

Every 30 minutes, reads all workflows from the n8n instance via REST API, extracts scheduleTrigger and cron nodes, compares the live state against a Google Sheets state store, and syncs Google Calendar with recurring events representing each workflow's schedule.

State (Calendar EventID, schedule string, On Calendar flag) is persisted in a Google Sheets tab.


Data flow

flowchart LR
	A["Schedule Trigger\\nevery 30 min"] --> B["Get many workflows\\nn8n REST API"]
	B --> C["Code: parsing\\nextracts scheduleTrigger/cron"]
	C --> D["Code: save current values\\nsnapshots live fields"]
	D --> E["Sheets: Lookup\\nreads saved state"]
	E --> F["Code: manual merge\\njoins live + Sheets"]
	F --> G["Code: detect changes\\ncreate / update / skip"]
	G -->|create| H["Remove Duplicates"]
	G -->|update| H
	G -->|update| I["Code: split eventIds\\nfor old event deletion"]
	H --> J["Code: RRULE\\nbuild GCal payload"]
	J --> K["Create an event\\nGoogle Calendar"]
	K --> L["Code: post-create\\naggregates event IDs"]
	L --> M["Sheets: OnCalendar=YES\\nupdates state store"]
	I --> N["Delete old event\\nGoogle Calendar"]

Prerequisites

Resource Purpose Notes
n8n instance with API enabled Read workflow list Self-hosted or cloud
Google Cloud Project Service Account + OAuth2 Same GCP project for both
Google Sheets State store Sheet ID hardcoded in workflow
Google Calendar Event destination Account [email protected]
Error workflow Error notifications ID: 0Ye3A2hKHqZJlJ0d

Setup

1 · n8n API Key

  1. In n8n: Settings → API → Generate API Key
  2. Copy the key
  3. In n8n Credentials → create n8n API → paste the key and the instance URL