Unified connector for Gmail, Google Drive, and Google Calendar.
Google Workspace Connector
A single connector that ingests Gmail messages, Drive documents, and Calendar events into CortexDB. Domain-wide delegation gives the connector access to all configured users; OAuth alternatively scopes it to one user.
Info
Two ways to run this connector:
- Run it yourself (Free + paid) —
pip install 'cortexdb-connectors[google-workspace]'thencortexdb-sync sync google-workspace. The connector reads your token from~/.cortexdb/state.json(written bycortexdb init) or from env vars. - Managed sync (Starter and up) — CortexDB runs the connector as a worker on its infrastructure. Configure it once from your dashboard; CortexDB handles webhook registration, retries, backfill, and idempotency.
1. Prepare credentials in Google Cloud
- Google Cloud Console → APIs & Services → enable Gmail, Drive, and Calendar APIs.
- Create a service account; generate a JSON key.
- Admin console → Security → API controls → Manage Domain Wide Delegation. Add the service account's client ID with these scopes:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/drive.readonlyhttps://www.googleapis.com/auth/calendar.readonly
2. Configure in your CortexDB dashboard
- Sign in at cortexdb.ai/login.
- Settings → Connectors → Add Connector → Google Workspace.
- Upload the service-account JSON key.
- Enter the delegated user emails to sync (comma-separated, e.g.
[email protected], [email protected]). - Pick which sources to enable: Gmail, Drive, Calendar.
- Set the scope template. Default:
org:<your-org>/source:google/user:{user_email}. - Click Start sync.
What gets written
| Source | Event | Modality |
|---|---|---|
| Gmail | Incoming message | conversation (role=user) |
| Gmail | Outgoing message | conversation (role=assistant if drafted by an agent, else user) |
| Drive | Doc created/edited | document |
| Drive | Comment | conversation; preceded_by links to doc |
| Calendar | Event created/updated | observation; attendees as labels |
| Calendar | Recording / Meet transcript | conversation per speaker |
idempotency_key shapes:
- Gmail:
gmail:<user>:<message_id>:<history_id> - Drive:
drive:<file_id>:<modified_time> - Calendar:
gcal:<calendar_id>:<event_id>:<updated>
Run it yourself
If you'd rather host the connector yourself instead of using CortexDB's managed worker, every connector ships in the cortexdb-connectors PyPI package:
pip install 'cortexdb-connectors[google-workspace]'
# Step 1: get a CortexDB token + actor (one-time, free tier)
pip install cortexdb-cli
cortexdb init
# Step 2: supply the connector's third-party credentials
export GW_SERVICE_ACCOUNT_KEY=... # required
export GW_DELEGATED_USER=... # required
# Step 3: one-shot sync, or `watch` for a poll loop
cortexdb-sync sync google-workspace
cortexdb-sync watch google-workspace --interval 60
cortexdb-sync reads your CortexDB token + actor from ~/.cortexdb/state.json automatically. Cursor state is persisted in ~/.cortexdb/connectors-state.json, so re-running picks up where the last cycle left off.
See also
- POST /v1/experience
- Bi-temporal queries — calendar events have
valid_from/valid_tonaturally