Skip to main content

Gmail Trigger

Type ID: gmailTrigger  ·  Kind: Trigger  ·  Trigger style: poll  ·  Trace: CHAIN

Polls the Gmail API on an interval and triggers the workflow when new emails matching the configured filters are received.

Credentials

Gmail

Properties

PropertyKeyTypeRequiredDefaultPossible valuesShown when
Poll IntervalpollIntervalMsnumberYes60000Interval in milliseconds to check for new emails (minimum 60 seconds)Always
EventeventoptionsYesmessageReceivedmessageReceived (Message Received)Always
OutputoutputoptionsNosimplesimple (Simplified), raw (Raw), fields (Select Included Fields)Always
FieldsfieldscheckboxYes[]id, threadId, labelIds, snippet, historyId, internalDate, payload, sizeEstimate, raw, classificationLabelValuesoutput = fields
FiltersfiltersobjectNo{}See sub-tableAlways
OptionsoptionsobjectNo{}See sub-tableAlways

filters (object)

PropertyKeyTypeRequiredDefaultPossible values
Read StatusreadStatusoptionsNounreadboth (Unread and read messages), unread (Unread messages only), read (Read messages only)
SendersenderstringNo''Email address to match (from:)
Subject ContainssubjectContainsstringNo''Text the subject must contain (subject:)
Has AttachmenthasAttachmentbooleanNofalseOnly return messages with attachments
LabellabelstringNoINBOXGmail label, e.g. INBOX, SENT, IMPORTANT

options (object)

PropertyKeyTypeRequiredDefaultPossible values
Mark as ReadmarkAsReadbooleanNofalseMark emails as read after triggering
Max Emails Per PollmaxEmailsnumberNo10Max emails processed per poll (clamped to 1-50)

Notes

Fires via poll(). Uses a stateless time window: each poll queries emails received between now - pollIntervalMs and now. A Gmail search query is assembled from the filters — is:unread/is:read (from readStatus), label:<label>, from:<sender>, subject:<subjectContains>, has:attachment, and a date bound after:YYYY/MM/DD derived from the window start. Because Gmail's after: filter is date-granular, each fetched message's internalDate is re-checked against the precise fromTime and messages older than the window are skipped.

Message detail format follows output: raw requests format=raw; simple and fields request format=full. simple runs each message through simplifyMessage; fields keeps only the selected keys; raw returns the full API object. If markAsRead is set, the UNREAD label is removed from each emitted message (failures are logged, not fatal).

When no messages fall within the window (before or after the precise time check) the node returns null and the workflow does not trigger. Otherwise it emits one item whose json contains emails (array) and a summary with count, subjects, senders, pollInterval, and polledAt.

The trigger() method (manual/test runs) delegates to poll(). When used as a non-root internal node, execute() instead returns a wait item on the poll channel so the wait orchestrator initiates polling.