All Collections
Triggers
Email Trigger V2
Email Trigger V2

Know the trigger and how to use it.

Micaella Mazoni avatar
Written by Micaella Mazoni
Updated over a week ago

We support the IMAP protocol only.

Let’s say you’re on Canvas and want to receive data from an email inbox. With the email trigger, you can make such integrations.

Example:

1. Open the trigger configurations and select the email-trigger type.

2. Fill the configuration fields:

  • Account: specify the account for the trigger to access the correct email.

  • Operation: choose the option "mark as read" (there’re other options, which will be explained later).

  • Hostname: insert the IMAP server hostname (eg.: imap.uol.com).

  • Port: determine the port.

  • Email Folder: define the name of the folder / inbox that the trigger must read (eg.: inbox). This folder can’t hold more than 100 messages (read/not read).

  • Destination Email Folder: specify which folder the message must be moved to (the field is displayed only when the option "move to another folder" is chosen).

  • Maximum Timeout: fill the maximum time for the trigger execution.

  • Allow Redelivery Of Messages: if enabled, the option allows the messages to be delivered again in the Pipeline Engine fails.

3. Click on "Confirm".

4. Continue to build the pipeline.

5. Connect the components.

6. Deploy the pipeline:

  • Click on "Runtime", located in the superior part of the screen.

  • Select the environment, which can be test or prod.

  • Click on "Create a new implantation".

  • Select the pipeline with its version and capacity.

  • Click on "Confirm".

7. When triggered, the pipeline will receive a payload similar to this one:

{
"textMessage": "",
"htmlMessage": "Hello, Peter\r\nI still haven’t received the report for this month. Could you send it by the end of the day?",
"attachments": ["attachment_fileName1", "attachment_fileName2", "attachment_fileName3"]
"subject": "Monthly report",
"from": [
"Renato Peixe Junior <renato.peixe@gmail.com>"
],
"to": [
"peter.gomes@gmail.com"
],
"cc": [],
"bcc": [],
"replyTo": [
"Renato Peixe Junior <renato.peixe@gmail.com>"
],
"sentDate": "2020-02-10T17:54:40Z[UTC]",
"receivedDate": "2020-02-10T17:54:52Z[UTC]"
}

  • data: message content

  • subject: message subject

  • from: sender email

  • to: recipient email

  • cc: recipients in copy

  • bcc: recipients in hidden copy

  • replyTo: email the answer is sent to

  • sentDate: date when the message was sent

  • receivedDate: date when the message was received

KNOW (AND UNDERSTAND) THE OPTIONS OF THE “OPERATION” FIELD

  • mark as read: select this option if, after being processed, you want the message to be marked as “read”.

  • move to another folder: select this option if, after being processed, you want the message to be moved to a predetermined folder. The destination is specified in the "Destination email folder" field, which only appears in the configurations when "move to another folder" is selected.

  • delete: select this option if, after being processed, you want the message to be deleted.

Attachments

If there's some attachment in the body of the message received by the trigger, it will download them and make them available inside the pipeline execution directory. The attachment names will be contained inside the attachments property and this property will be an array of strings containing the attachments names.

IMPORTANT: if there’re 2 attachments with the same name in the message, an unique identifier will be added in the name of the downloaded attachment.

Example

There’re 2 attachments with the name "file.csv" inside the message. Therefore, the content of the attachments property will be:

{
"attachments": ["file.csv", "0072e485-8ba2-4f79-bba5-8068e37ee792_file.csv"]
}

The identifier varies at each execution.

P.S.: If you use Gmail as IMAP server host, it will be necessary to authorize the support of non-safe applications. Click here to see the step-by-step.

Did this answer your question?