gmail.onNewEmail handles new inbox messages for triage, routing, attachment processing, or reply preparation.
Trigger data matches Get message, including headers, message bodies, labels, and attachment File objects.
Example
automations/read-new-email.automation.ts
Options
Call
gmail.onNewEmail() without options to use the project binding. The watched account can’t change at runtime.
Trigger data
ReturnsSignal<Message> for each qualifying message:
email.messageId to actions. Use email.transform(...) to derive other values.
Behavior
- Only messages newly added to Gmail’s
INBOXqualify. Existing inbox messages aren’t replayed when you deploy the trigger. - Automate.ax parses the complete raw message before starting the automation. It includes attachments and inline message parts as
Fileobjects. - Automate.ax derives
textfromhtmlwhen the message has no plain-text alternative. - An authenticated Automate.ax message doesn’t wake the automation that sent it. Other automations watching the mailbox still receive the event.
- Automate.ax uses Gmail message IDs for idempotency, so repeated provider notifications for the same message don’t create duplicate events.
Email formats vary.
html, text, from, and sender-supplied date fields
can be absent, while receivedAt can be null. Handle optional fields when
your automation accepts mail from varied senders.