Overview
The Google integration imports content from Gmail, Google Calendar, and Google Drive as searchable Trix memories. Each service syncs independently with configurable scopes.
- Gmail - Import emails with configurable label filtering
- Calendar - Import events with attendees and AI-powered briefings
- Drive - Import documents with folder-level filtering
- Automatic Sync - Background sync every 30 minutes
- Token Refresh - Automatic handling of OAuth token expiry
New Features: Gmail label preferences, Drive folder filtering, and automatic scheduled sync now available! Configure exactly which content gets synced.
Connecting Google
Via CLI (Recommended)
# Connect to Google (opens browser for OAuth)
trix google connect
# View connection status
trix google status
# List all Google connections
trix google listThe connect command opens your browser for OAuth authorization. Select which Google services
you want to grant access to (Gmail, Calendar, Drive).
Via API
# Initiate OAuth flow
curl -X POST https://api.trixdb.com/v1/integrations/oauth/initiate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider": "google", "scopes": ["gmail", "calendar", "drive"]}'You can request specific scopes during connection. Available scopes: gmail, calendar, drive.
Gmail Sync
New: Gmail Label Filtering!
Configure which Gmail labels to sync with fine-grained control. Only sync the labels you need!
What Gets Synced
Each email becomes a memory with:
| Memory Field | Source |
|---|---|
content | Email subject + body text |
content_type | text |
metadata.source | google_gmail |
metadata.from | Sender email address |
metadata.to | Recipient email addresses |
metadata.subject | Email subject line |
metadata.thread_id | Gmail thread ID |
tags | ["google", "gmail", "email"] + labels |
Gmail Label Configuration
Configure which Gmail labels to sync using the CLI:
# List all available Gmail labels
trix google gmail labels list <connection-id>
# View current label sync preferences
trix google gmail labels preferences <connection-id>
# Enable syncing for specific labels
trix google gmail labels enable <connection-id> INBOX SENT IMPORTANT
# Disable syncing for specific labels
trix google gmail labels disable <connection-id> SPAM TRASH
# Discover and sync label list from Gmail
trix google gmail labels sync <connection-id>API - Label Management
# List available labels with sync status
curl https://api.trixdb.com/v1/integrations/connections/{id}/gmail/labels \
-H "Authorization: Bearer YOUR_API_KEY"
# Get current label preferences
curl https://api.trixdb.com/v1/integrations/connections/{id}/gmail/preferences \
-H "Authorization: Bearer YOUR_API_KEY"
# Enable/disable a specific label
curl -X PUT https://api.trixdb.com/v1/integrations/connections/{id}/gmail/labels/{labelId} \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sync_enabled": true}'
# Sync label list from Gmail API
curl -X POST https://api.trixdb.com/v1/integrations/connections/{id}/gmail/sync-labels \
-H "Authorization: Bearer YOUR_API_KEY"By default, only INBOX is synced. You must explicitly enable other labels. System labels like SPAM and TRASH are available but typically kept disabled.
Calendar Sync
New: Advanced Calendar Features!
Google Calendar now includes AI-powered pre-meeting briefings, real-time webhooks, and multi-calendar support. View full Google Calendar guide
What Gets Synced
Each calendar event becomes a memory with:
| Memory Field | Source |
|---|---|
content | Event title + description |
content_type | text |
metadata.source | google_calendar |
metadata.event_start | Event start time (ISO 8601) |
metadata.event_end | Event end time (ISO 8601) |
metadata.attendees | List of attendee emails |
metadata.location | Event location if set |
tags | ["google", "calendar", "event"] |
Drive Sync
What Gets Synced
Google Docs are exported as text and become memories:
| Memory Field | Source |
|---|---|
content | Document text content |
content_type | text |
metadata.source | google_drive |
metadata.drive_url | Document URL |
metadata.mime_type | Original MIME type |
tags | ["google", "drive", "document"] |
Supported File Types
- Google Docs - Exported as plain text
- Google Sheets - Exported as CSV (first sheet)
- Google Slides - Exported as plain text (speaker notes)
- PDF files - Text extraction (if text layer present)
Drive Folder Configuration
Control which Drive folders to sync using fine-grained preferences:
# List all accessible Drive folders
trix google drive folders list <connection-id>
# View current folder sync preferences
trix google drive folders preferences <connection-id>
# Enable syncing for specific folders
trix google drive folders enable <connection-id> <folder-id-1> <folder-id-2>
# Disable syncing for specific folders
trix google drive folders disable <connection-id> <folder-id>
# Discover and sync folder list from Drive
trix google drive folders sync <connection-id>
# Configure recursive sync for a folder
trix google drive folders set-recursive <connection-id> <folder-id> trueAPI - Folder Management
# List available folders with sync status
curl https://api.trixdb.com/v1/integrations/connections/{id}/drive/folders \
-H "Authorization: Bearer YOUR_API_KEY"
# Get current folder preferences
curl https://api.trixdb.com/v1/integrations/connections/{id}/drive/preferences \
-H "Authorization: Bearer YOUR_API_KEY"
# Enable/disable a specific folder
curl -X PUT https://api.trixdb.com/v1/integrations/connections/{id}/drive/folders/{folderId} \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sync_enabled": true, "sync_recursive": true}'
# Sync folder list from Drive API
curl -X POST https://api.trixdb.com/v1/integrations/connections/{id}/drive/sync-folders \
-H "Authorization: Bearer YOUR_API_KEY"Folder Filtering: If no folder preferences are configured, all accessible folders are synced. Configure preferences to sync only specific folders and reduce noise.
Automatic Scheduled Sync
New: Automatic Background Sync!
Google connections now automatically sync every 30 minutes in the background. No manual triggers needed!
All active Google connections are automatically synced every 30 minutes by the background scheduler. This ensures your Trix memories stay up-to-date with your latest Gmail messages, Calendar events, and Drive documents.
How It Works
- Automatic Discovery: Scheduler finds all active connections every 30 minutes
- Intelligent Syncing: Only syncs connections that haven't been synced in the last 30 minutes
- Incremental Updates: Uses delta sync to fetch only new/updated items
- Token Refresh: Automatically refreshes expired OAuth tokens before syncing
- Error Handling: Failed syncs are retried with exponential backoff
Manual Sync Override
You can still trigger manual syncs at any time using the CLI or API:
# Force an immediate sync via CLI
trix google sync <connection-id>
# Via API
curl -X POST https://api.trixdb.com/v1/integrations/connections/{id}/sync \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_type": "incremental"}'Rate Limits: Manual syncs are subject to Google API rate limits. The automatic scheduler includes intelligent rate limiting and backoff to stay within quotas.
CLI Command Reference
The trix google command provides comprehensive Google integration management:
Connection Management
# Connect to Google
trix google connect
# List all connections
trix google list
# View connection details
trix google status <connection-id>
# Disconnect
trix google disconnect <connection-id>Manual Sync
# Trigger immediate sync
trix google sync <connection-id>
# Force full re-sync (slower, re-imports everything)
trix google sync <connection-id> --fullCalendar Management
# List available calendars
trix google calendar list <connection-id>
# View calendar preferences
trix google calendar preferences <connection-id>
# Enable/disable specific calendars
trix google calendar enable <connection-id> <calendar-id>
trix google calendar disable <connection-id> <calendar-id>
# Configure sync range
trix google calendar set-range <connection-id> <calendar-id> --past 30 --future 90All CLI commands support --help for detailed usage information. Run trix google --help to see all available subcommands.
API Reference
# List connections
curl -X GET https://api.trixdb.com/v1/integrations/connections \
-H "Authorization: Bearer YOUR_API_KEY"
# Trigger sync (all services)
curl -X POST https://api.trixdb.com/v1/integrations/connections/{id}/sync \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_type": "incremental"}'
# Trigger sync (specific service)
curl -X POST https://api.trixdb.com/v1/integrations/connections/{id}/sync \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_type": "incremental", "service": "gmail"}'
# Disconnect
curl -X DELETE https://api.trixdb.com/v1/integrations/connections/{id} \
-H "Authorization: Bearer YOUR_API_KEY"Rate Limits
Google APIs have per-service quotas. Trix handles this automatically:
| Service | Limit | Notes |
|---|---|---|
| Gmail | 250 quota units/second | List = 5 units, Get = 5 units |
| Calendar | 100 requests/second | Per calendar |
| Drive | 1000 requests/100 seconds | Export operations count as 1 |
Trix automatically queues requests and uses exponential backoff when approaching rate limits.
Troubleshooting
Token Expired
Google access tokens expire after 1 hour. Trix automatically refreshes them using the refresh token. If refresh fails:
trix integrations disconnect conn_abc123
trix integrations connect googleMissing Content
- Check if the content is accessible with your Google account
- Verify the correct scopes were granted during OAuth
- For shared Drive files, ensure you have at least viewer access
Large Mailboxes
For large Gmail accounts, initial sync may take time. Use filters:
# Sync only recent emails
trix integrations sync conn_abc123 --service gmail --since "7d"
# Sync specific labels only
trix integrations sync conn_abc123 --service gmail --labels "IMPORTANT"Gmail sync respects your Google account's trash and spam settings. Deleted and spam emails are not synced by default.