Skip to main content

An email arrives in a mailbox

Triggermailbox-email

Starts when a new email arrives in a mailbox you connect over IMAP, such as an Exchange or company mailbox.

At a glance​

PropertyValue
Trigger namemailbox-email
ResourceClusterTrigger (lumen.ai/v1alpha1)
Sourceevent
Needs a connectionyes, one that provides mailbox
Producesemail, file
Emitsitem
Installation must providenothing

A flow using this trigger names a Connector in connectorRef. Connection types that provide mailbox: [Mailbox (IMAP)](/reference/connections/imap-mailbox), [Microsoft 365](/reference/connections/microsoft-365).

The trigger goes under spec.triggers of a Flow. Its outputs are referenced as <triggerId>.<field>. A trigger can also carry a when condition ("Start only when") and disabled: true.

Outputs​

A later node references an output as {nodeId.field} in text, or nodeId.field in a condition.

OutputType
fromstring
tostring
subjectstring
bodystring
attachmentsnumber
senderVerifiedboolean
receivedAtdate
messageIdstring

Settings​

Set under config: on the flow trigger.

SettingTypeDefaultDescription
folderstring"INBOX"Folder is the mailbox folder to watch; unset is INBOX.maxLength 255
filtersobject-Filters keep only the mail that matches; leave them out to take everything.
filters.fromContainsstring-Sender containsmaxLength 200
filters.subjectContainsstring-Subject containsmaxLength 200
afterHandlingobject-AfterHandling says what happens to a mail the flow took.
afterHandling.modestring"markRead"Thenone of markRead, moveTo, leave
afterHandling.folderstring-Folder is where moveTo puts the mail.maxLength 255
pollMinutesinteger5PollMinutes is how often the mailbox is looked at.minimum 1; maximum 60
includeAttachmentsbooleantrueIncludeAttachments takes the mail's files along; unset is true.
requireAttachmentbooleanfalseRequireAttachment drops mail that carries no file; unset is false, so a mailbox trigger saved before the setting takes every mail as it did.
maxSizeMBinteger25MaxSizeMB refuses a mail bigger than this; unset is 25.minimum 1; maximum 40
importExistinginteger0Takes the newest N mails in the folder, before the filters, once when the folder is first read. More than 50 are worked off over several checks.minimum 0; maximum 500
attachmentsstring-Each attachment separately: every file goes through the flow on its own, with the email's sender, subject and body, so reply and forward steps answer once per file. The whole email as one: all the files travel together as one document. A trigger saved before this setting existed works as the whole email as one.one of separate, together
includeInlinebooleanfalseInclude images in the email body

The full JSON Schema of these settings: mailbox-email.schema.json.

Use it in a flow​

flow.yaml
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
name: my-imap-mailbox
namespace: tenant-acme
spec:
classRef: {name: imap-mailbox}
config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: mailbox-email-example
namespace: tenant-acme
spec:
displayName: "An email arrives in a mailbox"
triggers:
- id: start
ref: {name: mailbox-email}
connectorRef: {name: my-imap-mailbox}
next: [notify-in-app]
nodes:
- id: notify-in-app
stepRef: {name: notify-in-app}
config:
body: 'Total: {total}'
title: New invoice from {supplier}
to: admins