Communication
Gmail
Search Gmail, retrieve attachments, label messages and send or reply to email from an OrgSDK action using a project OAuth credential.
View 13 plugin functions ↓Use Gmail in a project
- Triage a label by priority and surface threads that need a reply
- Send a reply within an existing email thread
- Retrieve attachments such as invoices and expense reports
- Label receipt emails after a project action processes them
- Send templated notifications or reports with attachments
Access and credentials
The Google OAuth scope permits full mailbox access. The listed tools read messages and attachments, change labels and read status, and send email.
OAuth connections use your own provider application and client credentials. Configure that application in OrgSDK, review its permissions and connect the credential to your project.
Find unread messages
In Studio, open your project’s Plugins page and enable Gmail. Connect the account you want to use. Paste this example into an action in the same project.
// Look for up to ten messages that are still marked unread.
return await gmail.getMessages({
"query": "is:unread",
"maxResults": 10
});Use with OrgSDK
OrgSDK gives external AI clients persistent projects and controlled execution. Plugins add optional tools to those projects. Each run uses pinned plugin versions, and project configuration determines which credentials they can use.
Set up OrgSDK locally ↗Capabilities
13 functions from this published version. Read calls retrieve or process information; write actions can change data in the connected service.
13 of 13 functions
gmail.getMessages
Read callFetch Gmail messages using Gmail search query syntax (q). Label filters must use the label name (not the label ID), e.g. label:Expense or label:"Expense Reports". Returns cleaned text body optimized for LLM processing. HTML is converted to clean text, tracking pixels and quoted chains are removed.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
query | string | — |
maxResults | number | — |
Returns Promise<Array<{ id: string; threadId?: string; subject?: string; from?: string; date?: string; body: string; headers?: Record<string, string>; labelIds?: string[]; attachments?: Array<{ filename: string; mimeType?: string; attachmentId: string; size?: number }> }>>
gmail.getMessage
Read callFetch a single Gmail message by ID. Returns cleaned text body optimized for LLM processing. HTML is converted to clean text, tracking pixels and quoted chains are removed.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
id | string | — |
Returns Promise<{ id: string; threadId?: string; subject?: string; from?: string; date?: string; body: string; headers?: Record<string, string>; labelIds?: string[]; attachments?: Array<{ filename: string; mimeType?: string; attachmentId: string; size?: number }> }>
gmail.listLabels
Read callList Gmail labels (id + name)
Parameters and return value
This call takes no parameters.
Returns Promise<Array<{ id?: string; name?: string }>>
Get or create a Gmail label by name; returns label object (id + name)
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
name | string | — |
Returns Promise<{ id?: string; name?: string }>
Add/remove Gmail label IDs on a message. Use removeLabelIds:['UNREAD'] to mark as read.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
messageId | string | — |
addLabelIds | string[] | — |
removeLabelIds | string[] | — |
Returns Promise<{ success: boolean; id?: string; labelIds: string[] }>
Batch add/remove label IDs across multiple message IDs
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
messageIds | string[] | — |
addLabelIds | string[] | — |
removeLabelIds | string[] | — |
Returns Promise<{ success: boolean; count: number }>
Mark Gmail message as read (removes UNREAD label)
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
messageId | string | — |
Returns Promise<{ success: boolean; id?: string; labelIds: string[] }>
Mark Gmail message as unread (adds UNREAD label)
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
messageId | string | — |
Returns Promise<{ success: boolean; id?: string; labelIds: string[] }>
Send an email via Gmail. Supports plain-text or HTML body. When html is provided, sends a multipart/alternative message with both text/plain and text/html parts.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
to | string | — |
subject | string | — |
body | string | — |
html | string | — |
cc | string | — |
bcc | string | — |
Returns Promise<{ success: boolean; id: string; threadId?: string }>
Send an email with file attachments via Gmail. Builds a MIME multipart/mixed message with a plain-text or HTML body and one or more base64-encoded attachments. When html is provided, the body is nested in multipart/alternative.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
to | string | — |
subject | string | — |
body | string | — |
html | string | — |
attachments | Array<{ filename: string; mimeType: string; base64Data: string }> | — |
cc | string | — |
bcc | string | — |
Returns Promise<{ success: boolean; id: string; threadId?: string }>
Reply to a Gmail message within its thread. Fetches the original message to set threading headers (In-Reply-To, References) and replies to the original sender. Supports HTML via multipart/alternative when html parameter is provided.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
messageId | string | — |
body | string | — |
html | string | — |
cc | string | — |
bcc | string | — |
Returns Promise<{ success: boolean; id: string; threadId?: string }>
gmail.getMessageAttachment
Read callFetch a Gmail attachment by messageId + attachmentId. Returns standard base64 bytes (dataBase64).
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
messageId | string | — |
attachmentId | string | — |
Returns Promise<{ messageId: string; attachmentId: string; size?: number; dataBase64: string }>
gmail.getThread
Read callFetch all messages in a Gmail thread by threadId, in chronological order. Unlike getMessages, this preserves quoted reply chains so the full conversation context is available. Use this before replying to understand the complete thread history.
Parameters and return value
| Parameter | Type | Details |
|---|---|---|
threadId | string | — |
Returns Promise<Array<{ id: string; subject?: string; from?: string; to?: string; date?: string; body: string; threadId?: string; labelIds?: string[] }>>
