Skip to content

About

Notion Worker that automatically syncs Google Drive files to Notion databases with full document content. Export Notion pages back to Drive. Built on @notionhq/workers SDK.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

notion-google-drive-sync-worker

notion-google-drive-sync-worker

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


What it does

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

Drive → Notion (automatic, hourly)

Hourly automatic sync

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

Synced Notion database

Notion → Drive (on-demand via AI agent)

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.

Notion AI export to Drive

Bidirectional sync


Setup

Prerequisites

  • Node.js >= 22
  • A Notion workspace with Custom Agents enabled
  • A Google Cloud project with the Drive API enabled

1. Clone and install

git clone https://github.com/samihalawa/notion-google-drive-sync-worker.git
cd notion-google-drive-sync-worker
npm install

2. Create Google OAuth credentials

GCP OAuth configuration

  1. Go to Google Cloud Console > Credentials
  2. Enable the Google Drive API
  3. Create an OAuth 2.0 Client ID (Web application type)
  4. Add https://www.notion.so/workers/oauth/callback as an authorized redirect URI
  5. Copy the Client ID and Client Secret

3. Deploy

Terminal deployment

# 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 googleDriveAuth

4. Verify

ntn workers sync status
ntn workers exec searchDrive -d '{"query": "meeting notes", "maxResults": 5}'

How it works

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         |

Capabilities

driveSync (sync, automatic)

  • 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_IDS env var. If empty, syncs all recent Drive files.

exportPageToDrive (tool)

  • Reads all blocks from a Notion page via the Notion API
  • Converts to markdown (headings, lists, todos, code blocks, quotes, callouts, dividers)
  • Uploads as .md file to Drive (create new or update existing)
  • Target folder configurable per call

searchDrive (tool)

  • Full-text search across all Google Drive files
  • Returns name, type, link, modified date

readDriveFile (tool)

  • Reads any Drive file's text content
  • Exports Google Workspace files as plain text
  • Truncates at 50K chars

uploadToDrive (tool)

  • Upload any text content as a file to Drive
  • Supports both create and update operations

Configuration

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.

Finding a Drive folder ID

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

Development

npm run check       # Type-check
npm run build       # Compile TypeScript
ntn workers deploy  # Deploy to Notion

Built with

License

MIT

About

Notion Worker that automatically syncs Google Drive files to Notion databases with full document content. Export Notion pages back to Drive. Built on @notionhq/workers SDK.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages