Gmail Integration
Connect your Gmail account to create email drafts directly from Archivus, powered by AI-generated content.
Overview
The Gmail integration allows you to create email drafts in your Gmail account from within Archivus. This is particularly useful for:
- Sending AI-generated summaries via email
- Sharing document analysis with colleagues
- Creating professional emails from document content
- Replying to email threads with document insights
Quick Start
- Connect Gmail - Go to Settings > Integrations and click Connect on Gmail
- Authorize - Sign in with your Google account and grant permissions
- Create Drafts - Use the “Send to Email” feature in document views or chat
Prerequisites
Before connecting Gmail:
- Google Account - A personal or Google Workspace account
- Gmail Access - Gmail must be enabled for your account
- Archivus Account - Any paid plan
Connecting Gmail
Step 1: Navigate to Integrations
Go to Settings > Integrations in Archivus.
Step 2: Connect Gmail
- Find Gmail in the list of available integrations
- Click Connect
- You’ll be redirected to Google’s sign-in page
Step 3: Authorize Archivus
- Sign in with your Google account
- Review the permissions requested:
- Create, read, update, and delete drafts - Required for draft creation
- Send emails on your behalf - Only used when you explicitly send
- Click Allow to authorize
Step 4: Confirm Connection
After authorization:
- You’ll be redirected back to Archivus
- The Gmail integration will show as “Connected”
- Your Gmail email address will be displayed
Permissions Explained
Archivus requests minimal permissions:
| Permission | Purpose |
|---|---|
| Compose/Draft access | Create drafts in your Gmail |
| Send emails | Send drafts you approve |
What Archivus CANNOT do:
- Read your existing emails
- Access your contacts
- Modify your settings
- Access other Google services
Creating Email Drafts
From Document Chat
- Chat with a document to generate insights
- Click Send to Email on any AI response
- A draft is created with the content
- Review and send from Gmail
From Document Summary
- Open a document’s summary view
- Click Share via Email
- Select content to include
- Draft is created in Gmail
From Compare Results
- Complete a document comparison
- Click Export to Email
- Comparison results become a draft
Draft Features
Markdown to HTML
Content is automatically converted:
- Markdown headings → HTML headings
- Bold/italic → Formatted text
- Lists → Proper HTML lists
- Links → Clickable hyperlinks
- Code blocks → Formatted code
Pre-fill Options
When creating a draft, you can optionally specify:
| Option | Description |
|---|---|
| To | Recipient email addresses |
| CC | CC recipients |
| Subject | Email subject line |
Reply Support
Reply to existing email threads:
- Provide the Gmail thread ID
- Draft is created as a reply
- Maintains conversation context
API Reference
Get OAuth URL
Get the authorization URL to connect Gmail:
curl -X GET https://api.archivus.app/api/v1/gmail/auth-url \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"auth_url": "https://accounts.google.com/o/oauth2/v2/auth?...",
"state": "random-state-token"
}
Get Connection Status
Check if Gmail is connected:
curl -X GET https://api.archivus.app/api/v1/gmail/connection \
-H "Authorization: Bearer YOUR_API_KEY"
Response (Connected):
{
"connected": true,
"connection": {
"id": "conn_abc123",
"gmail_email": "user@gmail.com",
"is_active": true,
"connected_at": "2024-01-15T10:30:00Z",
"last_used_at": "2024-01-20T14:22:00Z"
}
}
Response (Not Connected):
{
"connected": false
}
Create Draft
Create a draft in the user’s Gmail:
curl -X POST https://api.archivus.app/api/v1/gmail/draft \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "# Summary\n\nThis is the document summary...",
"to": ["recipient@example.com"],
"cc": ["manager@example.com"],
"subject": "Document Analysis Results"
}'
Response:
{
"draft_id": "r1234567890",
"message_id": "1234567890abcdef",
"gmail_url": "https://mail.google.com/mail/#drafts/1234567890abcdef",
"message": "Draft created successfully"
}
Create Reply Draft
Create a draft that replies to an existing thread:
curl -X POST https://api.archivus.app/api/v1/gmail/draft \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Based on my analysis of the attached documents...",
"reply_to_id": "thread_abc123def"
}'
Disconnect Gmail
Remove the Gmail connection:
curl -X DELETE https://api.archivus.app/api/v1/gmail/connection \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"message": "Gmail disconnected successfully"
}
Use Cases
1. Share Document Summary
// After generating a document summary
const response = await fetch('/api/v1/gmail/draft', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: documentSummary,
to: ['team@company.com'],
subject: `Summary: ${documentTitle}`
})
});
const { gmail_url } = await response.json();
window.open(gmail_url, '_blank');
2. Send Analysis to Client
import requests
# Create draft with document analysis
result = requests.post(
'https://api.archivus.app/api/v1/gmail/draft',
headers={
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
},
json={
'content': f'''
# Document Analysis Report
## Key Findings
{key_findings}
## Recommendations
{recommendations}
---
*Generated by Archivus AI*
''',
'to': [client_email],
'subject': f'Analysis: {document_name}'
}
)
print(f"Draft created: {result.json()['gmail_url']}")
3. Weekly Report Distribution
# Create weekly summary and draft email
summary = generate_weekly_summary()
draft = create_gmail_draft(
content=summary,
to=['leadership@company.com'],
cc=['team@company.com'],
subject=f'Weekly Document Report - Week {week_number}'
)
Security
Token Management
- OAuth 2.0 - Industry-standard authorization flow
- Encrypted storage - Tokens encrypted with AES-256-GCM
- Auto-refresh - Tokens automatically refreshed before expiry
- Secure revocation - Disconnect removes all stored tokens
Best Practices
- Review drafts - Always review before sending
- Limit recipients - Only share with intended recipients
- Check content - Verify AI-generated content is accurate
- Disconnect when done - Remove connection if no longer needed
Troubleshooting
“Gmail not connected”
Cause: No active Gmail connection for your account.
Solution:
- Go to Settings > Integrations
- Click Connect on Gmail
- Complete the authorization flow
“Gmail connection is inactive”
Cause: The connection token has expired or been revoked.
Solution:
- Go to Settings > Integrations
- Disconnect Gmail
- Reconnect and re-authorize
“Failed to create draft”
Cause: Various issues with draft creation.
Solutions:
- Verify Gmail is connected
- Check if the email addresses are valid
- Ensure you have Gmail access (not blocked by workspace admin)
- Try disconnecting and reconnecting
“OAuth state expired”
Cause: Authorization took longer than 5 minutes.
Solution:
- Start the connection process again
- Complete authorization within 5 minutes
“Content too large”
Cause: Draft content exceeds size limits.
Solution:
- Split content into multiple drafts
- Summarize content before sending
- Remove unnecessary formatting
FAQ
Can I read my emails through Archivus?
No. Archivus only has permission to create drafts and send emails. It cannot read your existing emails.
Does Archivus send emails automatically?
No. Archivus only creates drafts. You must review and send emails manually from Gmail.
Can I connect multiple Gmail accounts?
Currently, one Gmail account per user. Contact support for multi-account needs.
What happens to drafts if I disconnect?
Drafts already created remain in your Gmail. Disconnecting only removes Archivus’s ability to create new drafts.
Is this available on mobile?
Yes. The Gmail integration works from any device where you access Archivus.
Endpoints Summary
| Endpoint | Method | Description |
|---|---|---|
/gmail/auth-url |
GET | Get OAuth authorization URL |
/gmail/callback |
GET | OAuth callback (handled automatically) |
/gmail/connection |
GET | Get connection status |
/gmail/connection |
DELETE | Disconnect Gmail |
/gmail/draft |
POST | Create a draft |
Next Steps
- Google Drive Migration - Import documents
- Document Chat - Generate content to share
- API Reference - Complete API documentation
Questions? Contact support@archivusdms.com