Skip to main content

Create an email trigger

Email triggers run when receiving an email or file attachment at a pre-set email address. Before creating an email trigger, you need to set up IMAP and generate an app password for the email you want to use.

Set up IMAP and app password

Before using email triggers, you need to enable IMAP settings on your email so that the email messages can be accessed from Swarm. If you use Gmail, you can set IMAP from the Forwarding and POP/IMAP tab on the settings screen. Make sure you enable IMAP access and click the Save Changes button when finished.

You will also need to generate an app password in your email to use in the Swarm triggers. An app password is a long, randomly generated password that gives an app or device permission to access your email. The app password can be generated from the security settings of your email account. You may need to specify the name of the app or device that will use the password. Once you get the app password from your email, add this password as an Data Store Item in Swarm.

Set up an email trigger

To create an email trigger, click the Create button at the top right of the Triggers screen.

Create email trigger button

Enter the trigger name, select Email as the type, and select the environment in which the trigger will run. After that, select the type of trigger event. There are 2 types of events you can use in an email trigger, i.e., New Email and New Attachment. A New email trigger runs based on incoming emails, while a New attachment trigger is based on file attachments received in incoming emails.

Enter trigger details

After that, enter the email hostname. You can find the hostname from the settings screen of the email you are using. Some examples of frequently used hostnames are imap.gmail.com for Gmail, outlook.office365.com for Outlook, imap.mail.yahoo.com for Yahoo! email, and imap.mail.me for iCloud email. Then, enter the username and select the app password that you have set as an environment variable.

You can specify which mailbox the trigger will monitor in the Mailbox field. By default, the trigger will monitor the INBOX or the primary mailbox of your email. You can also set conditions for the trigger to run when receiving emails with certain criteria by using the Search feature. This feature works the same as the search bar in your email. It is useful if you want to run a flow only when receiving certain emails, for example, emails from a certain sender or emails containing some keyword in the subject.

When finished, click the Save button.

note

A trigger email will take a maximum of 50 emails for each execution