Api_syncedGuides
Google Integrations - Quick Start Guide
Synced from the source repositories. Do not edit by hand.
For detailed implementation plan, see: GOOGLE_INTEGRATIONS_PLAN.md
๐ฏ Goal
Enable Gmail and Google Drive integrations that feed into workflow automation.
๐ Timeline: 7 Days (Nov 18-24)
| Day | Phase | Focus |
|---|---|---|
| 1 | OAuth Setup | GCP project, OAuth flow, token management |
| 2-3 | Google Drive | File listing, import, Drive picker UI |
| 4-5 | Gmail | Email listing, attachments, Gmail picker UI |
| 6 | Workflow Integration | External file input nodes, triggers |
| 7 | Testing & Polish | End-to-end testing, bug fixes |
๐๏ธ Architecture Overview
Frontend (turfai-sandbox)
โ API Calls
Backend (turfai/dms)
โ OAuth 2.0
Google Cloud Platform (Drive API, Gmail API)Key Components:
- OAuth service for authentication
- Drive/Gmail services for API calls
- Webhook handlers for auto-triggers
- Workflow integration for file sources
๐ OAuth Flow
- User clicks "Connect Google Drive"
- Frontend opens OAuth popup โ Google login
- User authorizes โ Google redirects to callback
- Backend exchanges code for tokens
- Tokens stored encrypted in database
- Frontend shows "Connected" โ
๐ Google Drive Features
User Can:
- Browse Drive folders
- Search files
- Import PDFs/images to workflows
- Auto-process new files (webhook)
Use Cases:
- Import contracts from shared folder
- Process invoices uploaded to Drive
- Extract data from archived documents
๐ง Gmail Features
User Can:
- View emails with attachments
- Import email attachments (PDFs, images)
- Auto-process incoming emails (webhook)
- Filter by sender/subject
Use Cases:
- Process invoice emails automatically
- Extract data from receipts sent via email
- Monitor vendor communications
๐ Workflow Integration
New Features:
-
External File Input Node
- Source selector: Upload | Drive | Gmail
- File picker for each source
- Auto-download to GCS
-
Workflow Triggers
- Gmail: "When email from X arrives with attachment"
- Drive: "When file added to folder Y"
- Auto-execute workflows
๐ ๏ธ Tech Stack
Backend:
googleapis- Google APIs client@google-cloud/storage- GCS uploads@google-cloud/pubsub- Webhooks- Strapi content types for data
Frontend:
- React components for pickers
- OAuth popup handler
- Integration status UI
๐ฆ Database Schema
New Content Types:
- integrations - Registry of available integrations
- user-integrations - User connections & tokens
- workflow-triggers - Auto-execution rules
๐ Security Checklist
- Tokens encrypted at rest
- OAuth state parameter (CSRF protection)
- Private token fields in API
- Webhook signature verification
- User-scoped access control
- Rate limiting
- HTTPS only
๐งช Testing Plan
Must Test:
- OAuth authorization flow
- Token refresh mechanism
- Drive file import
- Gmail attachment import
- Workflow execution with external files
- Webhook auto-triggers
- Error handling (revoked access, API errors)
๐ Day 1 Checklist (Tomorrow)
Morning
- Review full plan document
- Answer open questions (file size limits, cleanup policy)
- Create/configure GCP project
- Enable Drive & Gmail APIs
- Create OAuth credentials
- Add env variables to
.env
Afternoon
- Create Strapi content types (integrations, user-integrations)
- Install
googleapispackage - Create GoogleOAuthService
- Create OAuth API routes
- Test OAuth flow with Postman
Evening
- Start GoogleDriveService
- Implement file listing
- Test Drive API calls
- Commit progress
๐ก Quick Commands
Start backend:
cd ../turfai/dms
npm run developStart frontend:
cd turfai-sandbox
npm run devTest OAuth flow:
curl http://localhost:1338/api/oauth/google/authorize๐ Key Files to Create
Backend (turfai/dms):
src/
services/
google-oauth.js # OAuth flow
google-drive.js # Drive API
gmail.js # Gmail API
webhook.js # Webhook handler
api/
oauth/
routes/google.js
controllers/google.js
integrations/
routes/google-drive.js
routes/gmail.js
controllers/google-drive.js
controllers/gmail.js
webhooks/
routes/google.js
controllers/google.jsFrontend (turfai-sandbox):
src/
components/
integrations/
GoogleOAuthButton.tsx
GoogleDrivePicker.tsx
GmailPicker.tsx
IntegrationCard.tsx
pages/
Integrations.tsx (update)
lib/
api.ts (add integration APIs)๐ฏ Success Criteria
After 7 days, users should be able to:
- โ Connect Google account via OAuth
- โ Browse and import Drive files in workflows
- โ Browse and import Gmail attachments in workflows
- โ Create workflows that auto-execute on new emails
- โ See integration status and manage connections
- โ Disconnect and revoke access
๐ Let's Ship It!
Tomorrow we start with OAuth setup. Get some rest! ๐