Gmail - Setup Guide
Setup and configuration guide for Gmail integration
Gmail API integration for automated email management with Axellero.
For detailed instructions on managing credentials, connectors, and triggers in Axellero Studio, see the Integration Guide.
Step 1: Create Credential
Getting OAuth 2.0 Credentials from Google Cloud
- Go to Google Cloud Console
- Create a new project or select existing one
- Navigate to APIs & Services → Library
- Search for "Gmail API" and click Enable
- Go to APIs & Services → OAuth consent screen
- Select User Type (Internal or External)
- Fill in required fields (App name, Support email)
- Add the required scopes (see table below)
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Select Web application
- Add your OAuth callback URL to Authorized redirect URIs
- Click Create and save the Client ID and Client Secret
Required Scopes:
| Scope | Permission | Use Case |
|---|---|---|
gmail.readonly | Read | List/get messages, threads, labels |
gmail.send | Send | Send emails |
gmail.modify | Modify | Trash, label, modify messages |
gmail.labels | Labels | Create, update, delete labels |
gmail.compose | Compose | Create and send drafts |
Adding Credential to Axellero
- Navigate to Application > Integrations > Credentials
- Click "Add Credential"
- Select OAuth 2.0
- Enter:
- Name: "Gmail - Production"
- Client ID: From Google Cloud Console
- Client Secret: From Google Cloud Console
- Authorization URL:
https://accounts.google.com/o/oauth2/v2/auth - Token URL:
https://oauth2.googleapis.com/token - Scopes: Add the required scopes
- Click Save, then click "Authorize"
- Complete the Google sign-in and grant permissions
Axellero automatically handles token refresh and secure storage.
Step 2: Create Connector
- Navigate to Application > Integrations > Connectors
- Click "Add Connector"
- Select Gmail from the list
- Configure:
- Name: "Gmail - Production"
- Credential: Select the OAuth 2.0 credential you created
- Click Save
- Test the connection using the "Test" button (calls getProfile)
The connector is now available in any workflow or agentflow.
Step 3: Create Trigger
For supported events and payload examples, see main documentation.
3.1 Pub/Sub Prerequisites
Gmail triggers use Google Cloud Pub/Sub for real-time notifications.
- Go to Google Cloud Pub/Sub
- Click "Create Topic"
- Enter topic name (e.g.,
gmail-notifications) - Click "Create"
- Open your topic → Permissions tab
- Click "Add Principal"
- Add:
gmail-api-push@system.gserviceaccount.com - Assign role: Pub/Sub Publisher
- Click "Save"
Note the full topic name: projects/{project-id}/topics/{topic-name}
3.2 Create Trigger
- Navigate to Integrations > Triggers
- Click "Add Trigger" (+) button
- Select your Gmail connector
- Configure:
- Pub/Sub Topic: Full topic name from step 3.1
- Label Filter: Labels to watch (default: INBOX)
- Filter Behavior: Include or exclude specified labels
- History Types: Event types to track (messageAdded, labelAdded, etc.)
- Click Save
How it works: Axellero automatically sets up Gmail watch on your mailbox. When emails arrive, Gmail notifies Pub/Sub, which forwards to Axellero.
3.3 Create Push Subscription
- In Google Cloud Pub/Sub, go to your topic
- Click "Create Subscription"
- Select Push delivery type
- Enter the Axellero webhook URL (from trigger settings)
- Click "Create"
3.4 Add Trigger to Workflow
- Open Workflow Builder
- Find your trigger in the Triggers section
- Drag to canvas as starting node
- Build workflow logic after the trigger
3.5 Test the Trigger
- Send a test email to your Gmail account
- Check workflow execution logs in Axellero
- Verify trigger data via
{{ctx.nodes.gmail_trigger.outputs.data}}
Workflow Examples
Example 1: Auto-Forward Important Emails
Forward emails from VIP senders to Telegram.
Workflow Steps:
- Gmail Trigger: Events = messageAdded, Label = INBOX
- Condition: Check if sender matches VIP list
- Telegram - sendMessage: Forward to notification channel
Trigger Configuration:
{
"topicName": "projects/my-project/topics/gmail-notifications",
"labelIds": "INBOX",
"historyTypes": "messageAdded"
}Example 2: Support Ticket Creation
Create Linear issues from support emails.
Workflow Steps:
- Gmail Trigger: Events = messageAdded, Label = Support
- Gmail - getMessage: Fetch full email content
- Linear - createIssue: Create issue with email subject as title
Example 3: Daily Email Digest
Send a daily summary of unread emails.
Workflow Steps:
- Schedule Trigger: Daily at 9:00 AM
- Gmail - listMessages: Query
is:unreadwith limit 20 - Loop: For each message, get details
- Gmail - sendMessage: Send compiled digest
Configuration:
{
"q": "is:unread",
"maxResults": 20,
"labelIds": "INBOX"
}Example 4: Attachment Processing
Download and store attachments from incoming emails.
Workflow Steps:
- Gmail Trigger: Watch for new messages
- Gmail - getMessage: Get message with attachments
- Condition: Check if attachments exist
- Gmail - getAttachment: Download each attachment
- HTTP Request: Store attachment in external storage
Troubleshooting
| Error | Cause | Solution |
|---|---|---|
| 401 Unauthorized | Invalid or expired token | Re-authorize in credential settings |
| 403 Forbidden | Missing required scopes | Add scopes and re-authorize |
| 400 Invalid Grant | Refresh token revoked | Re-authorize from scratch |
| 403 Access Not Configured | Gmail API not enabled | Enable Gmail API in Cloud Console |
| 429 Rate Limited | Too many requests | Check quotas in Cloud Console |
| 403 User Rate Limit | Per-user quota exceeded | Wait and retry |
| Trigger not firing | Pub/Sub misconfigured | Verify topic permissions and subscription |
Common Issues
Token expires frequently
- Axellero handles token refresh automatically
- If still failing, re-authorize the credential
Trigger not receiving emails
- Verify Pub/Sub topic permissions include
gmail-api-push@system.gserviceaccount.com - Check push subscription endpoint URL is correct
- Ensure Gmail watch is active (auto-renewed by Axellero)
Missing emails in trigger
- Check label filter configuration
- Verify historyTypes includes the event you want
Security Best Practices
- Use Axellero Credential Manager for encrypted storage
- Axellero handles token refresh automatically
- Use minimum required scopes for your use case
- Monitor API usage in Google Cloud Console
- Review OAuth app permissions periodically