Gmail
gmail · Nodes · Providers
Runs Gmail provider operations.
Gmail#
Use Gmail in workflows to search and read messages and threads, send, reply and forward, work with drafts, label, archive, trash and restore messages, download attachments, and manage labels.
When to Use#
- Automating email triage and organization
- Sending notifications or reports via email
- Archiving or labeling emails based on content
- Building workflows that respond to email content
- Creating automated email follow-ups
- Syncing important emails to other systems
Supported Operations#
list_emails: Search and list emails with Gmail query syntaxget_email: Get full email content (headers/body based on format)list_threads: Search and list threads with Gmail query syntaxget_thread: Get a thread with all its messagessend_email: Send a new emailreply_to_email: Reply to one message in its existing thread, not reply-allforward_email: Forward a message to new recipients, the original attached wholelist_drafts,get_draft: List and read draftscreate_draft,update_draft: Write a draft (a new message or a reply) without sending itsend_draft: Send a draft as it standsdelete_draft: Delete a draft for goodmodify_labels: Add or remove labelsmark_read: Mark messages as read or unreadarchive: Remove messages from Inbox (keeps them in All Mail)trash: Move messages to Trash (a node saved withop: deletereads astrash)untrash: Restore messages from Trashdownload_attachment: Download one attachment's contentlist_labels,create_label,update_label,delete_label: Manage labels
All operations use the Gmail API through a Google OAuth connection.
Google OAuth and Send-As Requirements#
- Sending requires
gmail.sendorgmail.modify. - Replying requires both read and send permission:
gmail.readonlyplusgmail.send, orgmail.modify. - Listing or validating Gmail send-as aliases requires
gmail.settings.basic. - Existing Google connections must reconnect after OAuth scope changes before the new scopes are available.
- Verdalia uses Google OAuth user connections for Gmail sending. It does not use service accounts for this feature.
Send-As Aliases#
To send from an address other than the authenticated Gmail account, configure that address in Gmail or Google Workspace as a Send mail as alias first.
- The alias must be verified or accepted in Gmail/Google Workspace before Verdalia can send with it.
- Verdalia does not create, verify, or accept send-as aliases.
- Use
from_emailto select the verified send-as alias address. - Use
from_nameto set the display name for the messageFromheader. - If
from_emailis empty, Gmail sends from the authenticated account default address.
Configuration#
connection - Google connection to use
- Select from Settings → Connections
- Agents should call
list_connectionsand setconnectionto the returnedidULID - Use
nameonly for display; node configuration needs theid - Must be a Google OAuth connection with Gmail access
- Required in node config
operation - Operation to perform, one of the operations listed above, selected by op.
The node, the gmail agent tool group and verdalia.api.gmail run the same operations.
Operation: List Emails#
query - Gmail search query
- Supports full Gmail search syntax:
from:,to:,subject:,label:,is:, etc. - Examples:
"from:boss@company.com","subject:meeting","label:work is:unread" - Interpolatable from input
options - Optional request options
max_results: integer result limitlabel_ids: comma-separated label IDspage_token: thenextPageTokenof the previous page, to continue from it- Values can be interpolated from input
- Blank rows are skipped and duplicate keys use the last row
Operation: Get Email#
email_id - Email message ID
- The
idfield from ListEmails output - Interpolatable from input
- If empty or invalid, Gmail API returns an error
format - Response format
"minimal": Minimal fields"full": Full message with body (default)"raw": Raw RFC 2822 format"metadata": Headers and labels without the body
Operation: List Threads#
query and options work as for List Emails. The output lists threads, each with its
id and snippet, and nextPageToken when there is another page.
Operation: Get Thread#
thread_id - Gmail thread ID, the threadId of any of its messages. format works as for
Get Email and applies to every message. The output carries the thread's messages, oldest first.
Operation: Send Email#
options - Send options
to: comma-separated recipient email addresses- Values can be interpolated from input
- Blank rows are skipped and duplicate keys use the last row
- Must resolve to at least one recipient, or execution fails before sending
- Recipients must not contain CR/LF characters, or execution fails before sending
subject - Email subject
- Interpolatable text block
- Must not contain CR/LF characters, or execution fails before sending
body_text - Plain text body
- Interpolatable text block
- Used as fallback for HTML emails
body_html - HTML body (optional)
- Interpolatable text block
- If provided, creates multipart/alternative email
- Supports HTML formatting
attachments - Email attachments (optional)
- Interpolatable text block whose exact template can resolve at runtime to a binary value, a media reference/wrapper object, or a flat array of those values
- Wrapper objects may contain
binaryorobject_id, plus optionalfilenameandcontent_type - Media references resolve within the workspace; inline binary is used in transit and is not persisted
content_typedefaults toapplication/octet-stream- Each value becomes an attachment MIME part. With attachments, HTML bodies nest
multipart/alternativeundermultipart/mixed
from_email - Sender email address (optional)
- Must be the authenticated account address or a verified Gmail/Google Workspace Send mail as alias
- Verdalia validates listed aliases when the connection has
gmail.settings.basic - Verdalia does not create or verify aliases
- Interpolatable text
from_name - Sender display name (optional)
- Used with
from_emailfor the messageFromheader - Interpolatable text
- Ignored when blank
Operation: Reply to Email#
email_id - Gmail message id from list/get id or a Gmail trigger's message_id.
This is not the RFC Message-ID header or the Gmail thread id.
body_text, body_html, from_email, from_name, and attachments use the same interpolatable TextBlock formats as Send Email above.
The reply inherits the selected message's Subject exactly and sends to its Reply-To addresses, or From when Reply-To is absent. It does not reply-all, copy To/Cc/Bcc, or infer another correspondent when replying to your own sent message. Recipient, subject, and thread overrides are not accepted. Supply any quoted text or signature in the body; the original is not marked read.
Missing, ambiguous, or unsafe routing/thread metadata fails before sending. A present but unusable Reply-To does not fall back to From. A failed send is not retried automatically.
{
"gmail": {
"connection": "<Google connection ULID>",
"operation": {
"op": "reply_to_email",
"email_id": { "content": "{{ input.message_id }}" },
"body_text": { "content": "Acknowledged." },
"attachments": { "content": "{{ input.attachments }}" }
}
}
}
Operation: Forward Email#
email_id - Gmail message id of the message to forward.
options - to recipients, as for Send Email. body_text and body_html are a note
above the forwarded message; from_email, from_name and attachments work as for Send
Email.
The forward is a new message in a new thread. Its subject is the original's with Fwd: before
it, and the original travels whole, attachments included, as an attached message
(forwarded-message.eml, message/rfc822).
Operation: List Drafts and Get Draft#
list_drafts takes query and options (max_results, page_token; drafts cannot be
filtered by label). get_draft takes draft_id and format, which works as for Get Email.
A draft is { "id": "<draft id>", "message": { ... } }.
Operation: Create Draft and Update Draft#
A draft is written, never sent; send_draft sends it later. update_draft takes the
draft_id and replaces the draft's whole message.
- For a new message: options
torecipients and subject. - For a reply: reply_to_email_id, the Gmail message id to reply to. The draft inherits the recipient, subject and thread as Reply to Email does; leave subject and the recipients empty, or the draft is refused.
- body_text, body_html, from_email, from_name and attachments work as for Send Email.
Operation: Send Draft and Delete Draft#
draft_id - Draft ID. send_draft sends the draft as it stands and outputs the sent message;
the draft is gone afterwards. delete_draft deletes the draft for good (it does not go to the
trash) and outputs null.
Operation: Modify Labels#
email_id - Email message ID
- Interpolatable from input
- If empty or invalid, Gmail API returns an error
options - Label changes
add_labels: comma-separated label IDs to addremove_labels: comma-separated label IDs to remove- Values can be interpolated from input
- Blank rows are skipped and duplicate keys use the last row
Operation: Mark Read#
email_id - Email message ID
- Interpolatable from input
- If empty or invalid, Gmail API returns an error
read - Read status
true: Mark as read (default)false: Mark as unread
Operation: Archive#
email_id - Email message ID
- Removes from INBOX (equivalent to removing INBOX label)
- Interpolatable from input
- If empty or invalid, Gmail API returns an error
Operation: Trash#
email_id - Email message ID
- Moves to trash, where Gmail keeps it for 30 days (not permanent delete)
- A node saved with
op: deletereads astrash - Interpolatable from input
Operation: Restore from Trash#
email_id - Email message ID. untrash takes the message out of the trash.
Operation: Download Attachment#
email_id - Email message ID. attachment_id - the body.attachmentId of the message part,
from Get Email with format full.
destination - Where the attachment goes, by to:
output(default): the output is{ "size": <bytes>, "content": <binary> }; passcontentto a node that takes binary, such as Google Drive upload or an email attachment. A config saved withoutdestinationreads asoutput.library: the attachment is saved as a Library item, its type read from its bytes, and the output is the item's object descriptor (object_id,kind,content_type,filename,size_bytes,metadata).nameis the item's name,Gmail attachmentwhen empty.placedefaults to Folder (folder). Choose Other (other) to file the item outside every folder. Setfolderto folder slugs or ids from the Library root, separated by/. Every folder must already exist. Use the Library node's Create Folder first if you need a new folder.nameandfolderboth accept interpolation.
Operation: Labels#
list_labelsoutputs{ "labels": [...] }, system and user labels with theiridandname.create_labeltakes name (/nests it, as inClients/Acme), and optionally message_list_visibility (show,hide), label_list_visibility (labelShow,labelShowIfUnread,labelHide), text_color and background_color (hex codes from Gmail's palette, set together).update_labeltakes label_id and the same fields; a blank field stays as it is.delete_labeltakes label_id, deletes the label for good and outputsnull; messages keep their place but lose the label.
Retry#
retry - Whether each Gmail request is sent again after a failure that passes: a rate limit, a busy server, a dropped connection. Off by default; see Retries for how attempts and waits work. Listing, getting and downloading are reads, sent again freely, as are replacing a draft and deleting a draft or label, where a repeated delete can answer "not found" because the first attempt worked. Send, reply, forward and send draft repeat only an attempt Google refused before acting: the connection never opened, or Google answered 425 or 429; so do the other writes (creating a draft or label, changing labels, mark read, archive, trash, untrash). The gmail tool group takes the same setting.
Inputs#
input - Any input
- Used to trigger the node
- Data can be accessed for template interpolation
- Required
Outputs#
output - Gmail API response
For ListEmails:
{
"messages": [
{
"id": "18f3a2b4c5d6e7f8",
"threadId": "18f3a2b4c5d6e7f8"
}
],
"nextPageToken": "next_page_token_123",
"resultSizeEstimate": 42
}
For GetEmail:
{
"id": "18f3a2b4c5d6e7f8",
"threadId": "18f3a2b4c5d6e7f8",
"labelIds": ["INBOX"],
"snippet": "Email preview text...",
"payload": {
"headers": [
{"name": "From", "value": "sender@example.com"},
{"name": "To", "value": "you@example.com"},
{"name": "Subject", "value": "Subject Line"},
{"name": "Date", "value": "Mon, 1 Jan 2024 10:00:00 GMT"}
],
"parts": [
{
"mimeType": "text/plain",
"body": {
"data": "base64encodedtext"
}
}
]
}
}
For SendEmail, ReplyToEmail, ForwardEmail and SendDraft (the sent message id and its thread):
{
"id": "18f3a2b4c5d6e7f8",
"threadId": "18f3a2b4c5d6e7f8",
"labelIds": ["SENT"]
}
Examples#
Archive Read Emails#
[Gmail: ListEmails]
Config: query = "is:read label:inbox older_than:7d"
→ List of emails
[Branch: For each email]
→ email.id
[Gmail: Archive]
Input: email_id = {{email.id}}
Send Meeting Confirmation#
[Trigger: Form submission]
→ Form data with email, name, meeting_time
[Gmail: SendEmail]
Config:
options:
- key: to
value: {{input.form.email}}
subject: "Meeting Confirmed"
body_text: "Hi {{input.form.name}}, your meeting is scheduled for {{input.form.meeting_time}}."
Label Important Emails#
[Gmail: ListEmails]
Config: query = "from:ceo@company.com"
→ Emails from CEO
[Gmail: ModifyLabels]
Input:
email_id: {{result.messages[0].id}}
Config:
options:
- key: add_labels
value: IMPORTANT, STARRED
Runtime Errors#
| Error | Cause | Remediation |
|---|---|---|
| "Google connection is not selected" | connection field is empty |
Select a Google connection in node config |
| Connection not selected or unavailable | connection is empty or does not point to a usable Google connection |
Use list_connections, then set connection to the returned id ULID |
| OAuth token problem | Connection is not OAuth-based, token is missing, or token expired | Reconnect using Google OAuth |
| "This Google connection does not have Gmail access" | The connection's token lacks the Gmail scope the call needs | Reconnect the Google account and allow Gmail on Google's consent screen |
| "Gmail could not find the requested item" | Invalid message, thread, draft, label or attachment ID | Verify the ID from a list or get output |
| "Gmail API error 403" while replying | Gmail refused reading the original's headers; replying needs read and send permission | Check the included Gmail details and the connection's read permission |
| Missing or invalid parent headers | The original has no usable thread id, RFC Message-ID, or Reply-To/From, or has ambiguous/unsafe headers | Select a message with valid reply metadata; no unthreaded fallback is sent |
| Invalid message field | Subject or recipient contains unsupported newline characters | Remove CR/LF before sending |
| Invalid sender alias | from_email is not the authenticated account or a verified send-as alias |
Configure and verify the address as a Gmail/Google Workspace Send mail as alias |
| Rate limit exceeded | Too many API calls | Add delays between operations, batch requests |
Common Mistakes#
Mistake: Using label names instead of label IDs
- Error: Label not found
- Fix: Use label IDs like "INBOX", not display names
Mistake: Not handling pagination for large result sets
- Error: Only getting first page of results
- Fix: Check for
nextPageTokenand make additional requests
Mistake: Sending to invalid email addresses
- Error: "Invalid to header"
- Fix: Validate email addresses before sending
Mistake: Setting
from_emailto an address that is not a verified send-as alias- Error: Invalid sender alias or Gmail send failure
- Fix: Add the address in Gmail/Google Workspace as Send mail as, complete verification/acceptance, then reconnect if scopes changed
Tips#
- Use Gmail search operators for powerful filtering:
from:,to:,subject:,has:attachment,is:unread,older_than:, etc. - Email bodies are base64 encoded - decode using a script node if needed
- The
threadIdgroups related emails together - Archive removes from inbox but keeps the email accessible in All Mail
- Trash moves to trash (recoverable for 30 days with
untrash), not permanent deletion - For HTML emails, always provide a body_text fallback for plain text clients
Inputs
inputRequired
Outputs
output
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
connection | connection(google) | Yes | Google connection to use |
operation | tagged_union | No | Operation to perform |
retry | tagged_union | No | Sends a request again after a failure that passes: a rate limit, a busy server, a dropped connection. Off sends once. |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |