onNewEmail subscribes an automation to messages newly added to the connected Gmail inbox. Use it for inbound-email workflows such as triage, routing, attachment processing, and reply preparation.
The trigger emits the same fully parsed message shape as Get message, including headers, MIME bodies, labels, and attachment File objects.
Example
automations/read-new-email.automation.ts
Options
You can call
onNewEmail() without an options object. Unlike action inputs, the trigger’s account selection must be static: a Signal cannot choose which mailbox to watch at runtime.
Trigger data
Returns aSignal<Message> for each qualifying message:
email.messageId does in the example. Use email.transform(...) when you need to derive a new typed value from the complete message.
Behavior
- Only messages newly added to Gmail’s
INBOXqualify. Existing inbox messages are not replayed when you deploy the trigger. - Automate.ax parses the complete raw message before starting the automation. Attachments and inline MIME parts are included as
Fileobjects. textis derived fromhtmlwhen the message has no plain-text alternative.- Gmail message IDs are used for idempotency, so repeated provider notifications for the same message do not 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.