Gmail
Connect Gmail to ORQO so that agents can search, read, send, and manage emails through MCP tools.
| Category | Communication |
| Capabilities | MCP tools, receive (via Pub/Sub triggers) |
| Adapter path | /gmail |
| Auth method | OAuth 2.0 (shared Google credential) |
Gmail provides MCP tools for agents to interact with Gmail programmatically — searching inboxes, reading messages, composing emails, and managing labels. It also supports inbound email triggers via Google Cloud Pub/Sub for event-driven workflows.
Prerequisites
- A Google account with Gmail access
- A Google Cloud project with the Gmail API enabled
- OAuth 2.0 credentials (client ID and client secret)
- Access to the ORQO Settings area
Setup
1. Set Up Google Cloud Credentials
- Go to the Google Cloud Console.
- Create a project (or select an existing one).
- Enable the Gmail API under APIs & Services > Library.
- Navigate to APIs & Services > Credentials and create OAuth 2.0 Client ID credentials (or reuse credentials from another Google integration).
- Set the redirect URI to the OAuth Callback URL shown on the app's detail card in ORQO.
- Note the client ID and client secret.
2. Install the Gmail App in ORQO
- Navigate to Settings > Integrations in ORQO.
- Switch to the Catalog tab and find Gmail.
- Click the card to view details, then click Install.
3. Add or Link Credentials
Gmail uses the shared Google OAuth credential:
| Credential | Type | Description |
|---|---|---|
| GOOGLE_OAUTH2 | oauth2 | OAuth 2.0 credentials (client ID, client secret, tokens) |
Create the credential in Settings > Credentials with your Google Cloud client ID and client secret, then assign it to the Gmail app. If you already have a GOOGLE_OAUTH2 credential from another Google integration (Drive, Calendar), assign that same credential — no need to create a new one.
All Google integrations (Drive, Gmail, Calendar) share the same GOOGLE_OAUTH2 credential. Install any of them first — the others will reuse it.
4. Authorize via OAuth
- Click Connect with OAuth on the Gmail app card.
- Google's consent screen shows the requested Gmail permissions.
- Approve access. ORQO stores the tokens and refreshes them automatically.
Because all Google integrations use incremental authorization, authorizing Gmail adds the Gmail scope to your existing Google token — it does not revoke Drive or Calendar access.
5. Verify the Connection
Click Verify on the Gmail app card. This tests the connection and discovers the available MCP tools.
Available Tools
| Tool | Description |
|---|---|
gmail_search | Search emails using Gmail query syntax (same as the Gmail search bar) |
gmail_read_message | Read a full email — subject, from, to, date, body |
gmail_send | Compose and send a new email |
gmail_reply | Reply to an existing email thread (supports reply-all) |
gmail_create_draft | Save an email as a draft without sending |
gmail_list_labels | List all Gmail labels (Inbox, Sent, custom labels) |
gmail_modify_labels | Add or remove labels from an email (also used to archive by removing INBOX, or mark read by removing UNREAD) |
gmail_create_label | Create a new custom Gmail label (idempotent — returns existing label if name matches) |
These tools are discovered automatically when the app is verified and can be assigned to agents via Skills.
Search Query Examples
The gmail_search tool accepts the same query syntax as Gmail's search bar:
| Query | What it finds |
|---|---|
from:alice@example.com | Emails from Alice |
subject:quarterly report | Emails with "quarterly report" in the subject |
is:unread | Unread emails |
newer_than:2d | Emails from the last 2 days |
has:attachment filename:pdf | Emails with PDF attachments |
from:alice subject:report newer_than:7d | Combined filters |
Receive Capability (Triggers)
Gmail can receive inbound emails as trigger events via Google Cloud Pub/Sub. This lets you build workflows that react to incoming emails — triage, classification, auto-response, or routing to the right team.
How It Works
Gmail Inbox
+-- new email arrives
|
v
Google Cloud Pub/Sub
+-- topic: projects/{project}/topics/gmail-push
+-- subscription: push to ORQO webhook endpoint
|
v
ORQO Webhooks Controller
+-- parse-inbound -> { event_type: "email_received", ... }
+-- matches Trigger with event_type "email_received"
|
v
Workflow runs with email content as initial message
Prerequisites
- A Google Cloud Pub/Sub topic in your Google Cloud project.
- A push subscription on that topic, pointing to ORQO's webhook URL for the Gmail app.
- A Gmail watch registered via the Gmail API, directing push notifications to your Pub/Sub topic.
Gmail watches expire after 7 days. You must renew the watch periodically (via a cron job, Cloud Scheduler, or manual renewal). If the watch expires, inbound email notifications stop silently.
Setting Up a Trigger
- Create a Trigger on a workflow and set the event source to the Gmail app.
- Set the event type to
email_received. - When an email arrives, the trigger fires and the workflow receives the email body, subject, sender, and metadata.
Event Payload
The Gmail adapter parses inbound Pub/Sub notifications into this format:
| Field | Value |
|---|---|
event_type | email_received |
sender | The email's From address |
message | The email body (plain text, extracted from the message) |
metadata.subject | The email subject line |
metadata.gmail_message_id | The Gmail message ID (for use with gmail_read_message or gmail_modify_labels) |
dedup_key | The Gmail message ID (prevents duplicate processing on webhook retries) |
is_bot | true if the message was sent by the platform (has SENT label without INBOX) |
Example Use Cases
- Email triage — classify inbound emails by topic, urgency, or sender and apply labels automatically.
- Auto-response — detect specific patterns (support requests, meeting invitations) and draft or send replies.
- CRM routing — extract contact info from emails and create records in external systems.
- Digest generation — aggregate emails matching a query into a daily summary artifact.
Platform-Specific Behavior
- OAuth 2.0 with incremental scopes — Gmail uses the
gmail.modifyscope. When authorized alongside Google Drive or Calendar, scopes are merged into a single token. - Thread-aware replies — The
gmail_replytool preserves thread context, so replies appear correctly in the recipient's inbox as part of the conversation. - Receive via Pub/Sub, not SMTP — Gmail receives inbound emails through Google Cloud Pub/Sub push notifications, not SMTP. For SMTP-based email delivery through Doorkeeper channels, use the Email app instead.
- Feedback loop prevention — When agents send emails via
gmail_sendorgmail_reply, the adapter detects outbound messages (SENT label without INBOX) and setsis_bot: trueto prevent trigger loops.
What's Next
- Google Drive — file access using the same Google credential
- Google Calendar — calendar management using the same Google credential
- Create a Skill — bundle Gmail tools for agents
- Set Up an App — general app installation guide