Skip to content
Docs

Email Trigger

Email Trigger starts a flow when a new message lands in a mailbox. Every inbound email becomes a fresh run, and the parsed message is handed to the flow as its start data. Use it to log support requests, notify a team when a customer writes in, or hand an email to an agent to triage and reply. You find it on the node picker’s Triggers — start the flow shelf.

The node has a single webhook handle, which connects into Start’s trigger handle. Like every inbound trigger it is not one of the run’s steps: it decides when a run starts and what the start data is, and the run itself begins at Start.

A mailbox is where inbound mail arrives: an address Publicus hosts and you forward to, an IMAP account, or a provider account connected over OAuth. Create it first under Mailboxes; How to connect a mailbox walks through all three routes, including the connection an OAuth mailbox uses and the secret that holds an IMAP password.

One mailbox can start several flows: every flow whose Email Trigger points at it runs on each message it receives. Only mail that arrives after you create the mailbox starts a flow, so connecting an account with years of history does not replay it.

The Email Trigger node's settings form, with the fields described below
The Email Trigger node's settings form, with the fields described below
FieldTypeDefaultDescription
Mailbox (mailboxId)string ✦ (required) — The mailbox whose inbound mail triggers this flow.
Direction (direction)one of incoming, outgoing, both (optional) incoming Which mail starts this flow: what the mailbox receives, what is sent from it, or both. Sent mail is only read when the mailbox watches its sent folder.
Without overlapping (withoutOverlapping)boolean (optional) true When on, an email that arrives while an earlier run of this trigger is still working is skipped, not queued, and no run ever reads it. Turn it off for an inbox where every message needs an answer.

Fields marked ✦ accept expressions.

The parsed email is the run’s start data, under $start->payload. Read its fields in expressions, for example {{ $start->payload->subject }}.

{
"payload": {
"from": "sender@example.com",
"to": "you@example.com",
"subject": "Order #1234 hasn't arrived",
"text": "Plain-text body of the message.",
"html": "<p>HTML body, when the message has one.</p>",
"messageId": "<abc123@mail.example.com>",
"inReplyTo": "<prior@mail.example.com>",
"receivedAt": "2026-07-03T09:15:00Z",
"headers": { "X-Mailer": "…" },
"authentication": { "spf": "pass", "dkim": "pass", "arc": "none", "dmarc": "pass" },
"attachments": [
{ "id": "9m4e2mr0ui3e8a215n4g", "filename": "invoice.pdf", "mimeType": "application/pdf", "sizeBytes": 20481, "isInline": false, "contentId": null, "parentAttachmentId": null, "sourceUrl": null, "sourceProvider": null, "note": null },
{ "id": "9m4e2mr0ui3e8a215n50", "filename": "logo.png", "mimeType": "image/png", "sizeBytes": 4210, "isInline": true, "contentId": "logo@mail.example.com", "parentAttachmentId": null, "sourceUrl": null, "sourceProvider": null, "note": null }
],
"folder": "inbox",
"direction": "incoming"
},
"conversationKey": "3c5ebd54-5c46-5849-8617-e6cf2e478a3a"
}

Beside payload, $start->conversationKey names the email thread: every message in one thread with one sender carries the same key. Key an agent’s memory on it to keep one conversation per thread.

Payload field Description
from The sender’s address.
to The recipient the message was addressed to.
subject The subject line.
text The plain-text body. A message sent as HTML only gets a text version of its whole HTML body, so you can read text for every message. null only when the message has no body.
html The HTML body, when the message includes one.
messageId The message’s RFC Message-ID, or null when it arrived without one. Pass it to a reply’s replyToMessageId so the reply threads correctly.
inReplyTo The Message-ID this email replied to, or null.
receivedAt When the message was received, in ISO-8601.
headers The message’s headers as an object.
authentication Authentication results: spf, dkim, arc, and dmarc, each pass, fail, none, or another result the receiving mail server wrote. none means nothing was checked. dmarc is the one that says the mail came from the domain in from (see Before a flow answers on its own). Forwarding legitimately breaks SPF, so treat a failing spf as a signal, not a verdict.
attachments A list of attachment descriptors, each with id, filename, mimeType, sizeBytes, isInline, and contentId. mimeType is the type the sender gave the file, unless that says nothing about it: a photo that Outlook sends as application/octet-stream has the type its content shows, image/jpeg. isInline is true for an image the message shows in its body, such as a signature logo or a pasted screenshot, rather than attaching as a file. contentId is the id the HTML body uses to show it (cid:…), or null. From a Microsoft 365 mailbox, a file too large to store has a null contentId. To pass only real files on, leave out the entries where isInline is true. parentAttachmentId is the id of the forwarded message a file came out of, or null for a file attached directly (see Mail forwarded as an attachment). sourceUrl and sourceProvider describe a OneDrive or SharePoint link, and note says in words why an entry has no id or no stored file behind it.
folder The mailbox folder the message was read from, as the mailbox names it (for example inbox, sentitems, SENT, or a folder of your own), or null for a Publicus inbox.
direction incoming for mail the mailbox received, outgoing for mail sent from it and read from its sent folder.

To pass on only the files the sender attached, and not the logos and screenshots the message shows in its body, leave out the entries whose isInline is true:

{!! json_encode(array_values(array_filter($start->payload->attachments, fn ($a) => ! $a->isInline))) !!}

A message forwarded as an attachment (Outlook’s Forward as attachment, or a whole thread dragged into a new mail) is opened, from every kind of mailbox. The payload lists the forwarded message itself as an .eml file, then each file inside it as an attachment of its own, with parentAttachmentId pointing at the .eml:

[
{ "id": "9m4e2mr0ui3e8a215n60", "filename": "Tekeningen blok B.eml", "mimeType": "message/rfc822", "parentAttachmentId": null, "note": null },
{ "id": "9m4e2mr0ui3e8a215n6g", "filename": "Tekeningen blok B/K-201.pdf", "mimeType": "application/pdf", "parentAttachmentId": "9m4e2mr0ui3e8a215n60", "note": null }
]

(Entries shortened.) A file from a forwarded message is named <subject>/<file name>, and is read, forwarded or handed to an agent by its id like any other attachment. To leave the forwarded messages themselves out and keep their files, filter on the type:

{!! json_encode(array_values(array_filter($start->payload->attachments, fn ($a) => $a->mimeType !== 'message/rfc822'))) !!}

Two levels are opened: a forwarded message, and one forwarded inside that. Anything deeper is listed with a null id and a note. The files inside a forwarded message count toward the same size limits as the mail’s own attachments, and are kept before the .eml itself, so a forwarded thread too large to keep whole still yields its files. The .eml then has an id but its note says the message itself was not kept.

From a Microsoft 365 mailbox, a OneDrive or SharePoint link attached to a mail is listed with a null id, the link in sourceUrl where Microsoft provides it, and a note saying the file itself is not downloaded.

A mailbox can also read its sent folder (see Choose which folders to read). The trigger’s direction field decides which mail starts this flow:

direction Starts a run for
incoming (default) Mail the mailbox receives.
outgoing Mail sent from the mailbox, read from its sent folder.
both Either. Branch on {{ $start->payload->direction }} to handle them differently.

Keep incoming for a flow that answers mail. Given the mail you sent, such a flow would answer you: your own address is on its From line. A message the trigger does not take is recorded as skipped on the mailbox’s log, with the reason.

A reply or message a flow sends from this mailbox is never read back from the sent folder as new mail, so a flow that takes sent mail cannot trigger itself.

from is whatever the sender wrote, and anyone can write a known contact’s address there. A flow that looks the sender up and replies without a person can be made to write, in your name, to that contact.

Check dmarc first. It is pass only when the mail really came from the domain in from. Put a Switch or a Conditional Exit before the reply, on:

($start->payload->authentication->dmarc ?? 'none') === 'pass'

Send everything else to a person instead, for example through a Form or a message to the mailbox’s owner. The AI builder adds this check when it builds such a flow, and warns about one that lacks it.

  • A domain that publishes no DMARC record never passes, so its mail always goes to the person.
  • A Publicus inbox reports none for dmarc: mail through one always goes to the person. Connect the mailbox from Google or Microsoft 365 for a flow that should answer on its own.
  • From a mailbox connected by IMAP, the results are as reliable as the mail provider: one that checks nothing leaves the sender’s own claims in the message.

The Smoke / Email trigger — inbound mailbox template is the minimal wiring: an Email Trigger bound to a forward mailbox, into Start, into a Text Expression that echoes the message:

Inbound from {!! $start->payload->from !!}: {!! $start->payload->subject !!}

To hand the message to an agent instead, wire the trigger into an Agent node and read the body from {{ $start->payload->text }}.

  • The mailbox and the trigger are separate switches. Mail is ignored unless the mailbox is active and the trigger’s badge on the canvas is switched Active on.
  • With withoutOverlapping on (the default), a message that arrives while a previous run of the flow is still in progress is skipped, not queued. The skip is recorded as a receipt on the mailbox’s log.
  • A run that is waiting counts as in progress. A flow that pauses, at a Form asking somebody something or at an Await, therefore handles one message per wait while withoutOverlapping is on: everything that arrives before the answer, or the deadline, is skipped. Turn it off when each message should get its own run.
  • Triggered runs execute the flow’s published version; see Triggers & arming.