Creating an email trigger - The Email trigger starts an automation when the predefined email server receives an email. You can define the trigger conditions based on which the automation starts.

Automation 360

The Email trigger starts an automation when the predefined email server receives an email. You can define the trigger conditions based on which the automation starts.

About this task

Connect the Control Room to one of the email services on your system and trigger the automation when you receive a new email.

You can use OAuth 2.0 to authenticate any email server. For EWS server option, you must register your application with the Microsoft identity platform. For more information, see Connect action in Email package.

Before you begin

Ensure that you have the necessary permissions to create and run bots with triggers.

Procedure

  1. Go to Automation > Create > Task Bot on the left pane.
    The Create Task Bot modal appears.
  2. Perform the following actions in the Create Task Bot modal.
    1. Select the applicable platform.
      Select Windows for Windows platform or select macOS for macOS platform
    2. Enter a name for the bot in Name.
    3. Optional: Enter a description for the bot in Description.
    4. Optional: Click Choose and follow the prompts to select the storage location.
      By default, all the bots are stored in the \Bots folder.
    5. Click Create & edit.
      The bot editor page appears.
  3. Go to Triggers > Email trigger and double-click Email to add the trigger to the trigger section.
  4. Select one of the following server types as the trigger for your incoming emails in Connect to Email:
    Server typeSteps
    Microsoft Outlook Click Outlook.

    Microsoft Outlook installed on the bot runner device is set as the email service. The email trigger starts the automation when you receive an email in the Microsoft Outlook.

    Note: For macOS platform, use Microsoft Outlook (macOS) trigger.
    Email server Click Email server and perform the following steps.
    1. Enter the email service Host information.

      For example, if you are using Office365 as your email service, enter Outlook.office365.com.

    2. Select IMAP or POP3.
      IMAP and POP3 are protocols used to connect to the mail server that enables you to read your emails through an email client.
      Note: The POP3 protocol has a known limitation where any new calendar invite can also trigger the bot.
    3. Use secure connection (SSL/TLS): Select this option if you want to use a secure connection with the mail server.
    4. Enter the configured port number for your email server in Port.
    5. Select one of the following user authentication methods to sign in to the email server:
      • Basic
      • Client credentials
        • Specify the unique client and tenant IDs generated when you registered the application in the Microsoft Azure portal.
        • Specify the username you want to use to access the mail server.
        • Specify the client secret that you generated for your app in the app registration portal.
          For Client ID, Tenant ID, Username and Client Secret fields, choose from Credential or Insecure string tab:
          • Credential: Use a value available in the credential vault.
          • Insecure string: Manually enter a value.
          Note: Client Credentials flow does not support Gmail.
      • Control Room managed

        To use Control Room managed OAuth2 mode of authentication to automate Gmail, you must configure the OAuth connection in the Control Room. See Create OAuth connection.

        Update the information in the following fields:

        • Connection: Click the Pick button to select a connection type.
        • Select Custom in the Provider type field.
        • Select the connection name that you set up in the Control Room for Google Workspace apps.

        • Use the Token type field to select one of the following options:
          • Shared: Select this option when the OAuth2 access token is shared for all users running the automation.
            Note: This option requires the Control Room administrator or any user (with Manage connections and View connections options enabled for the OAUTH CONNECTIONS) to set up an OAuth connection in the Control Room. Save the login credentials one time to generate a shared access token that can be used by all users running the automation.
          • User-specific: Select this option when the OAuth2 access token is specific to each user running the automation.
            Note: This option requires the Control Room administrator or any user (with Manage connections and View connections options enabled for the OAUTH CONNECTIONS) to set up an OAuth connection in the Control Room. Ensure you do not save the login credentials so that each user running the automation can provide their login credentials and generate an access token that can only be used by that specific user.
          • Click Confirm.
        Note: When you use User-specific option, you must log in to your Google account to authenticate and generate a user-specific token. Perform the following steps to use this option:
        1. In the Control Room, navigate to your profile My settings > OAuth connections.
        2. Click Login to authenticate.
        3. Sign in to your Google account and select Continue.
        4. Verify the services you have access to and Click Continue.

          If the connection is succeeded, it will display the status as Active.

      Note: The Email in folder does not support sub-folders when you set the protocol as POP3 for Email Server,
    EWS server Click EWS server.
    1. From the Microsoft Exchange Version drop-down menu, select your current version.

      For example, if you are using Microsoft Exchange Service Pack 2, select Exchange2010_SP2 as your email service.

    2. Enter the domain name, for example, smtp.office365.com
    3. Select one of the following user authentication methods to sign in to the email server:
      • Basic
      • OAuth 2.0 - Client credentials
        • Specify the unique client and tenant IDs generated when you registered the application in the Microsoft Azure portal.
        • Specify the username you want to use to access the mail server.
        • Specify the client secret that you generated for your app in the app registration portal.
          For Client ID, Tenant ID, Username and Client Secret fields, choose from Credential or Insecure string tab:
          • Credential: Use a value available in the credential vault.
          • Insecure string: Manually enter a value.
          Note: There is no shared mailbox support for Microsoft Outlook but as a workaround, you can use the EWS server credentials flow with a shared email as a username string.
  5. Enter an appropriate trigger interval in the Check every drop-down menu.
    The bot uses a default trigger interval of 120 minutes.
    Note: The trigger interval defined in the Check every drop-down does not depend on the number of emails received during the interval. For example, if you set the interval as one second and receive three different emails at the same time, the trigger runs only once. The run time filter of polling is updated to the sent date time of the email for which the last trigger was run.
  6. Select the All incoming emails option in the Emails that will start the bot setting.
  7. Specify an appropriate trigger condition in the Select Conditions setting to specify an email event for the selected server type.
    • Email from: Select this check box and enter the email address of the sender in the text box. You can enter multiple email addresses in a semicolon-separated value format.
    • Email subject contains: Select this check box and enter a keyword that might be included in the subject line of the incoming email.
    • Email without an attachment: Select this check box to define the condition based on emails that do not contain an attachment.
    • Email with an attachment: Select this check box to define the condition based on emails that contain an attachment
    • Email in folder: Select this check box and enter the path of the folder in the text box. This condition is helpful when the mailbox contains predefined rules to save emails to a specific folder within the Inbox.
    Note: The Email from, Email subject contains, and Email in folder do not support wildcard entries.
    Consider a scenario where you want to configure a trigger in an automation for an Outlook mailbox that receives an email from a specific sender. In Select Conditions, select the Email from check box and specify the email address of the sender.

    When you select the Email subject contains check box, the email trigger is executed depending on the following subject conditions:

    • When the subject line is provided within double quotation marks (""), for example, "ABC spreadsheet", the trigger is executed only when the email subject has an exact match for the string provided within quotation marks.
    • When multiple subject lines are separated by semicolons, for example, ABC spreadsheet; ABC project logs, the trigger is executed when the email subject matches any of the subject lines mentioned.
  8. Optional: Specify a record variable to save the trigger response data.
    You can create a record variable using the Create variable icon or use an existing record variable to save the data. The trigger response data contains the following keys:
    • emailFrom
    • emailTo
    • emailSubject
    • emailMessage
    • emailReceivedDate
    • action
    • host
    • port
    You can use the information saved in these keys in the downstream actions within the automation session
  9. Click Save to save the email trigger configuration.

Results

Microsoft Outlook, Email server, or EWS server is set as the trigger to start the bot for new emails.
Note: When you run an email trigger, the emailTo key returns a list of To addresses. To convert the list of To addresses into a string, use the Assign action from the List package and then use the Join items action from the List package, with the comma as a delimiter to separate the addresses.

What to do next

Configure the required automation using the Actions, and save the automation. When you click Run > Run with triggers, the automation listens for the configured trigger. Once a new email arrives, the trigger starts the configured automation.