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), document source (email sync) |
| 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.
For a single Google account, all Google integrations (Drive, Gmail, Calendar) can share the same GOOGLE_OAUTH2 credential — install any of them first and the others will reuse it. To connect a different Google account, install Gmail again as a separate, named instance with its own credential (see Connect Multiple Mailboxes below).
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.
Connect Multiple Mailboxes
You can install Gmail more than once to connect several mailboxes to the same organization — for example a personal inbox and a shared sales inbox. When you install Gmail again, give the new install a distinct name (such as "Gmail – Personal" or "Sales Inbox") so you can tell the mailboxes apart.
Each Gmail install gets its own credential and is authorized independently with Connect with OAuth, so you sign in to each mailbox separately. In a workflow, different agents can use different mailboxes — their tools are kept separate automatically.
See Connect multiple accounts of the same service for the full walkthrough.
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.
Sync Emails to Documents (Knowledge Graph)
Beyond live triggers, Gmail can act as a document source: ORQO periodically pulls the emails carrying a chosen label into a project's document library, converts each to Markdown, and — when the project's Knowledge Graph is enabled — classifies them into the graph. This turns correspondence into a searchable knowledge base: investor updates, client threads, vendor docs, or your own sent decisions.
Resource Path = a Gmail label
When you connect Gmail as a source (Project → Documents → Connect Source → Gmail), the Resource Path is a Gmail label name — not a folder or a search. Only emails carrying that label are synced.
- Create a label in Gmail (for example
KG), apply it to the emails you want, then enterKGas the Resource Path. - To test immediately with no setup, use
SENT— your own outgoing mail.
Allowed labels: any custom label, plus SENT, STARRED, and IMPORTANT.
Rejected labels: INBOX, SPAM, TRASH, DRAFT, UNREAD, and the CATEGORY_* buckets — these are too broad and would flood your library. Point the source at a deliberate label instead.
A single label spans incoming and sent mail — labeling a sent email pulls it in alongside received ones. You can even build a workflow that reads your inbox and applies the KG label automatically (using gmail_modify_labels), so curation happens hands-free.
Options
| Field | For Gmail |
|---|---|
| Resource Path | A Gmail label name (e.g. KG, SENT) |
| Target Folder | Where synced emails land in the document library (e.g. emails) |
| Sync Every | How often ORQO checks for newly-labeled emails |
| File Filter | Optional Gmail search query to narrow the label (e.g. has:attachment) — not a filename glob |
How it syncs
- One document per email, rendered as Markdown — a header block (From / To / Date / Thread) followed by the body.
- A newly-labeled email — even an old one — is picked up on the next sync, so labeling is your per-message on/off switch.
- Removing the label stops future syncs of that email; the document already in your library is kept.
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 Chief of Staff 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.
Sending Files (Outbound)
Chief of Staff can attach files to the emails it sends — documents and artifacts from a project's library, or files shared earlier in the conversation. Any file type can be attached as a standard email attachment, subject to Gmail's overall message size limit (~25 MB).
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