Email Trigger

Know the trigger and how to use it.

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

We support IMAP protocol only, without attachments.

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

 
Example:

1. Open the trigger settings 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 are other options, which we'll explain ahead).

  • Hostname: insert the name of the IMAP server host (eg.: imap.uol.com).

  • Port: determine the port.

  • Email Folder: define the folder / inbox name that will be read (eg.: inbox). This folder cannot have more than 100 messages (read / unread).

  • Destination Email Folder: point which folder the message should be moved to (the field appears only when the option "move to another folder" is selected).

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

  • Allow Redelivery Of Messages: if activated, the option allows messages to be redelivered in case of Pipeline Engine failure.

   
​       

3. Click on "Confirm".
​   

4. Move on with the pipeline building.
​   

5. Connect its components.
​   

6. Deploy the pipeline:

- Click on "Runtime", located in the upper part of the screen.

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

- Click on "Create new deploy". 

- Select the pipeline with its version and capacity.

- Click on "Confirm".
​   

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

{
"textMessage": "",
"htmlMessage": "Hello, Pedro\r\nI still have not received the report for this month. Can you send it until the end of the day?",
"attachments": ["attachment_fileName1", "attachment_fileName2", "attachment_fileName3"]
"subject": "Monthly Report",
"from": [
"Renato Peixe Junior <renato.peixe@gmail.com>"
],
"to": [
"pedro.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: content of the message

  • subject: topic of the message

  • from: e-mail of the sender

  • to: e-mail of the recipient

  • cc: recipients put on copy

  • bcc: recipients put on blind-copy

  • replyTo: destination e-mail of the answer

  • sentDate: dispatch date of the message

  • receivedDate: receivement date of the message

     


“Operation" field

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

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

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

Attachments

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

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 property attachments will be:

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

The identifier varies at each execution.

    

P.S.: When using Gmail as the IMAP server host, it's necessary to authorize the support of less secure applications. Click here to see the step-by-step.

Did this answer your question?