A simple script to do 2 way-sync between Notion and Google Calendar using Cloudflare Workers.
- Google Calendar
- Notion
- Cloudflare Workers
- KV
- Trigger
- Create a new Google Calendar.
- Create a new Notion database with the following properties:
Name
: titleDate
: start / end date with timeEvent Id
: rich textTag
: selectMilestone
: checkbox
- Create a new integration in Notion and get the token. See: Notion doc
- Create a new service account in Google Cloud Console and download the JSON key.
- In Google Calendar, go to
Settings and sharing
->Share with specific people
and add the service account email withMake changes to events
permission. - Create a new Cloudflare Worker, and set the following secrets:
notion_token
: Notion integration tokennotion_database_id
: Notion database IDgoogle_calendar_id
: Google Calendar IDgoogle_private_key
: Google service account private keygoogle_client_email
: Google service account email
- Deploy the worker.
The title of the event in Google Calendar enclosed in []
will be treated as tag in Notion. For example, [Me]
will be treated as Me
.
If the event has tag Me
, the event will be created as private.
If the event in Notion has Milestone
checked, the event will be created as all day event in Google Calendar.
- The events with attendees are not supported.
- Date and time are formatted in UTC.
Environment variables for local development can be set in a .dev.vars
file. See: Cloudflare doc
# Install dependencies
npm install
# Run the worker locally
npm run start
# Deploy the worker
npm run deploy
# Test cron job locally
open "http://localhost:8787/__scheduled?cron=*/1+*+*+*+*"
MIT