A Notion Worker that continuously syncs Google Drive with Notion — full document content, automatic scheduling, bidirectional via AI agent tools.
Setup • How it Works • Capabilities • Configuration
| Capability | Direction | Trigger | Content |
|---|---|---|---|
driveSync |
Drive → Notion | Automatic, every hour | Full document text in page body |
exportPageToDrive |
Notion → Drive | AI agent or CLI | Markdown export |
searchDrive |
Search Drive | AI agent or CLI | File metadata |
readDriveFile |
Read Drive file | AI agent or CLI | Full text content |
uploadToDrive |
Upload to Drive | AI agent or CLI | Any text content |
Every hour, the worker scans your configured Google Drive folders (or all of Drive), extracts the full text content from every document, and upserts it into a Notion database. Each file becomes a page with:
- Full text content in the page body (Google Docs as text, Sheets as CSV, text/code files as-is)
- Metadata columns: name, link, file type, modified date, owner, size, source folder
- Automatic file type classification with emoji icons
- Recursive subfolder scanning
Tell the Notion AI agent: "Export this page to Google Drive" — the worker reads all blocks, converts to markdown, and uploads as a .md file.
- Node.js >= 22
- A Notion workspace with Custom Agents enabled
- A Google Cloud project with the Drive API enabled
git clone https://github.com/samihalawa/notion-google-drive-sync-worker.git
cd notion-google-drive-sync-worker
npm install- Go to Google Cloud Console > Credentials
- Enable the Google Drive API
- Create an OAuth 2.0 Client ID (Web application type)
- Add
https://www.notion.so/workers/oauth/callbackas an authorized redirect URI - Copy the Client ID and Client Secret
# Login to Notion
ntn login
# Set credentials
ntn workers env set GOOGLE_CLIENT_ID=your-client-id
ntn workers env set GOOGLE_CLIENT_SECRET=your-client-secret
# Optional: specify Drive folders to sync (comma-separated)
ntn workers env set DRIVE_FOLDER_IDS=folder-id-1,folder-id-2
# Deploy
ntn workers deploy
# Complete OAuth
ntn workers oauth start googleDriveAuthntn workers sync status
ntn workers exec searchDrive -d '{"query": "meeting notes", "maxResults": 5}'Google Drive Notion Workers Notion
| | |
| ---- driveSync (hourly) ---> | --- upsert pages ---------> |
| list files | with full text content |
| extract content | + metadata columns |
| | |
| <-- exportPageToDrive ------ | <--- read blocks ---------- |
| upload .md file | from Notion page |
| | |
| <-- uploadToDrive ---------- | <--- content from agent --- |
| create/update file | or CLI command |
- Schedule: Every 1 hour
- Mode: Replace (full refresh each cycle)
- Content extraction: Google Docs → text, Sheets → CSV, Slides → text, plain text/markdown/JSON/code → as-is
- Media handling: Images, videos, audio linked back to Drive (not downloaded)
- Limits: Files > 5MB linked only. Content truncated at 80K chars per file.
- Folders: Configured via
DRIVE_FOLDER_IDSenv var. If empty, syncs all recent Drive files.
- Reads all blocks from a Notion page via the Notion API
- Converts to markdown (headings, lists, todos, code blocks, quotes, callouts, dividers)
- Uploads as
.mdfile to Drive (create new or update existing) - Target folder configurable per call
- Full-text search across all Google Drive files
- Returns name, type, link, modified date
- Reads any Drive file's text content
- Exports Google Workspace files as plain text
- Truncates at 50K chars
- Upload any text content as a file to Drive
- Supports both create and update operations
All configuration via environment variables — no code changes needed:
| Variable | Required | Description |
|---|---|---|
GOOGLE_CLIENT_ID |
Yes | GCP OAuth client ID |
GOOGLE_CLIENT_SECRET |
Yes | GCP OAuth client secret |
DRIVE_FOLDER_IDS |
No | Comma-separated folder IDs to sync. Empty = sync all recent files. |
Open the folder in Google Drive. The URL contains the ID:
https://drive.google.com/drive/folders/1zSLWLEkoKolBlQ9xxmZn_8VFA_ECeWgV
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the folder ID
npm run check # Type-check
npm run build # Compile TypeScript
ntn workers deploy # Deploy to Notion@notionhq/workers— Notion Workers SDKntn— Notion Workers CLI- Google Drive API v3
MIT






