---
related_nodes: [gmail]
---

# Gmail Trigger

## Overview

Starts a workflow when new Gmail messages match the configured search.

This node appears in the `google` catalog category because that is the provider grouping. It is a trigger through node metadata. It has no input sockets and emits one event on the `output` socket.

Delivery is at-least-once. Downstream workflows should dedupe by `message_id`.

## Configuration

| Field | Description |
|-------|-------------|
| `connection` | Google OAuth connection `id` ULID from `list_connections`. Use the returned `id`, not the display name. |
| `query` | Gmail search query. Empty query matches messages selected by labels. |
| `label_ids` | Gmail label IDs to filter by. Defaults to `INBOX`. |

## Output

Socket: `output`

On success, the output remains the existing Gmail event data shape:

| Field | Type | Description |
|-------|------|-------------|
| `message_id` | string | Gmail message ID. |
| `thread_id` | string | Gmail thread ID. |
| `received_at` | string | RFC3339 timestamp from Gmail `internalDate`. |
| `snippet` | string \| null | Gmail-provided message preview. |
| `label_ids` | string[] | Gmail label IDs on the message. |
| `from` | string \| null | Sender header value. |
| `to` | string[] | Recipient header values. |
| `cc` | string[] | CC recipient header values. |
| `subject` | string \| null | Subject header value. |
| `date` | string \| null | Date header value. |
| `body_text` | string \| null | Decoded `text/plain` MIME body when present. |
| `body_html` | string \| null | Decoded `text/html` MIME body when present. |

`body_text` and `body_html` are decoded from Gmail MIME parts when present and may be null. Attachments and attachment bytes are not included.

## Runtime Errors and Notes

- Polling runs periodically, so delivery can lag message arrival.
- Each new matching message starts one run, in the order Gmail reported them, including messages that arrive while earlier runs are still going.
- The first poll records current state and skips existing matching mail.
- Invalid or missing Google connections prevent subscription. Use `list_connections` and set `connection` to the returned `id` ULID.
- Missing Gmail scopes cause Google API authorization errors.
- Polling and authorization errors start a workflow execution that fails at the trigger node through the normal workflow error pipeline.
- Use Gmail action nodes for historical backfills, labels, archive, or read-state changes.
