
Google Workspace MailReceivedTrigger
CertifiedPoll Gmail for newly received emails
Google Workspace MailReceivedTrigger
Poll Gmail for newly received emails
Polls Gmail for messages newer than the previous interval (default PT5M, min PT1M) and triggers an execution with the matches. Supports search query and label filters, optionally includes spam/trash. Limits processing to maxMessagesPerPoll (default 50).
type: io.kestra.plugin.googleworkspace.mail.MailReceivedTriggerExamples
Monitor inbox for any new email
id: gmail_new_messages
namespace: company.team
tasks:
- id: process_email
type: io.kestra.plugin.core.log.Log
message: "New email from {{ trigger.from }}: {{ trigger.subject }}"
triggers:
- id: watch_inbox
type: io.kestra.plugin.googleworkspace.mail.MailReceivedTrigger
clientId: "{{ secret('GMAIL_CLIENT_ID') }}"
clientSecret: "{{ secret('GMAIL_CLIENT_SECRET') }}"
refreshToken: "{{ secret('GMAIL_REFRESH_TOKEN') }}"
interval: PT5M
Monitor specific labels with query filter
id: gmail_urgent_messages
namespace: company.team
tasks:
- id: notify_urgent
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK') }}"
payload: |
{
"text": "Urgent email: {{ trigger.subject }} from {{ trigger.from }}"
}
triggers:
- id: watch_urgent
type: io.kestra.plugin.googleworkspace.mail.MailReceivedTrigger
clientId: "{{ secret('GMAIL_CLIENT_ID') }}"
clientSecret: "{{ secret('GMAIL_CLIENT_SECRET') }}"
refreshToken: "{{ secret('GMAIL_REFRESH_TOKEN') }}"
query: "is:unread label:urgent"
labelIds:
- INBOX
- URGENT
interval: PT2M
Properties
clientId *Requiredstring
OAuth 2.0 Client ID
The OAuth 2.0 client ID from Google Cloud Console
clientSecret *Requiredstring
OAuth 2.0 Client Secret
The OAuth 2.0 client secret from Google Cloud Console
refreshToken *Requiredstring
OAuth 2.0 Refresh Token
The OAuth 2.0 refresh token obtained through the authorization flow
accessToken string
OAuth 2.0 Access Token
The OAuth 2.0 access token (optional, will be generated from refresh token if not provided)
allowConcurrent Non-dynamicboolean
falseSpecifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.
includeSpamTrash booleanstring
falseInclude spam and trash
Whether to include SPAM and TRASH messages
initialLookback string
Initial lookback window
How far back to look on first run; defaults to polling interval
interval Non-dynamicstring
PT5MdurationPolling interval
How often to check for new emails; minimum PT1M, default PT5M
labelIds array
Label filters
Label IDs to restrict search (INBOX, SENT, UNREAD, etc.); empty searches all
maxMessagesPerPoll integerstring
50Messages processed per poll
Upper bound on messages processed each poll; default 50
query string
Gmail search query
Gmail search string (e.g., is: unread, from: sender@example.com, subject: important); empty monitors all
readTimeout integerstring
120The read timeout for the request (in seconds)
scopes array
["https://www.googleapis.com/auth/gmail.modify","https://www.googleapis.com/auth/gmail.readonly","https://www.googleapis.com/auth/gmail.send"]The OAuth scopes to use
List of OAuth 2.0 scopes required for the operation
stopAfter Non-dynamicarray
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTEDList of execution states after which a trigger should be stopped (a.k.a. disabled).
when string
trueA condition that determines whether the trigger should run.
A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.
Outputs
messages array
New messages detected
Messages created since last interval; trigger.subject/from/etc. mirror the first when only one exists
io.kestra.plugin.googleworkspace.mail.models.EmailMetadata
The BCC recipient email addresses
The CC recipient email addresses
The sender email address
The parsed headers of the message
The ID of the last history record that modified this message
The immutable ID of the message
date-timeThe internal message creation timestamp
List of IDs of labels applied to this message
Estimated size in bytes of the message
A short part of the message text
The message subject
The ID of the thread the message belongs to
The recipient email addresses