Configure a Microsoft Teams to trigger an action when an event occurs in the monitored Microsoft Teams chat. This example shows how to create a Task Bot with a Microsoft Teams trigger to send an email to a Microsoft 365 Outlook mailbox when a user posts a message in a specific channel within a team.

The following example shows how to configure a Microsoft Teams web trigger that starts the automation workflow when the user posts a message with the subject Critical in the General channel of the Help Desk team.

Prerequisites

Ensure that the following prerequisites are met:
  • Prerequisites mentioned in the Microsoft Teams Web triggers.
  • Active OAuth connection for Microsoft 365 Outlook and Microsoft Teams account.
  • A valid Microsoft Azure certificate stored in the Credential Vault. You can use the same certificate to authenticate the trigger and the action.
  • Record variables named MSTeamsTriggerData and OutlookTriggerData.

Procedure

  1. Perform the following steps to create a Task Bot
    1. On the left pane, click Automation.
    2. Click Create > Task Bot.
      The Create Task Bot wizard appears.
    3. Enter an appropriate name for the bot in the Name field.
      All the bots are stored in <\Bots> folder by default.
    4. Optional: Add a description for the bot in the Description field.
    5. Optional: Click Choose and follow the prompts to save the bot in a different folder.
    6. Click Create & Edit.
      The bot is created and the Bot editor page appears.
  2. Perform the following steps to add and configure the Microsoft Teams web trigger.
    1. Click Triggers > Microsoft Teams, and then double-click or drag Web trigger to add the web trigger to Triggers section.
    2. Click Pick to choose the preconfigured OAuth connection from the Pick an OAuth connection modal.
    3. Select Teams & Channel > Team Chat to choose team chat as trigger condition.
    4. Select When a new chat message is added in Listen to event.
    5. Enter Help Desk in Team name.
      You can also use the Select Team name button to navigate and select the team from the Teams modal.
    6. Enter General in Channel name.
      You can also use the Select Channel name button to navigate and select the team from the Channels modal.
    7. Enable Filter check box and then enter Critical in the Keywords to search for field.
    8. Select Certificate > Credentials > Choose and follow the prompts in the Pick a credential modal to select the Microsoft Azure certificate that is already available in the Credential Vault.
    9. Select MSTeamsTriggerData from the Response drop-down.
  3. Perform the following steps to add and configure the Message Box action.
    1. Click Actions > Message Box, and then double-click or drag Message Box action to add it to the Actions section.
    2. Enter an appropriate title for the message box in Enter the message box window title.
    3. Enter $MSTeamsTriggerData{subject}$ in Enter the message to display.
      The subject key from the trigger response data contains the subject of the chat message as its value.
    The Message Box serves as an alert for the chat message.
  4. Perform the following steps to add and configure the Microsoft 365 Outlook Connect action.
    1. Click Actions > Microsoft 365 Outlook, and then double-click or drag Connect to add the action to Actions section.
    2. Select Azure Global in Azure Cloud.
      If your Microsoft 365 Outlook is part of Microsoft 365 Government version, choose Azure US GCC High.
    3. Select Control Room managed in OAuth2 Authentication mode.
    4. Click Pick and follow the prompts in Pick an OAuth connection modal to choose the OAuth connection for Microsoft 365 Outlook.
    5. Click Variable > Insert a value and follow the prompts to choose the Microsoft 365 Outlook user name credential.
    6. Optional: Enter an appropriate session name in Create Microsoft 365 Outlook session.
      The system sets Microsoft365OutlookSession as the session name by default.
  5. Perform the following steps to add and configure the Microsoft 365 Outlook Send action.
    1. Click Actions > Microsoft 365 Outlook, and then double-click or drag Send to add the action to Actions section.
    2. Enter the session name that you had entered when configuring the Connect action.
      If the default name is retained, the system prefills Microsoft365OutlookSession as the Microsoft 365 Outlook session.
    3. Enter the Microsoft 365 Outlook mail id to which the file details must be forwarded in To.
    4. Enter an appropriate subject line in Subject.
      The system sets Automation Anywhere finished executing the TaskBot as the subject line by default.
    5. Select HTML code in Email body type and enter the $MSTeamsTriggerData{"body.content"}$
      The body.content key from the trigger response data contains the content of the chat message as its value.
      For more information about trigger response data, see Microsoft Teams trigger audit logs.
  6. Click Save to save the task bot.
When you click Run > Run with triggers, the system activates the trigger and the trigger starts listening for the When a new chat message is added event in the General channel of the Help Desk team. The trigger starts the subsequent Microsoft 365 Outlook actions when any user posts a message that contains the keyword Critical either in the subject or body, in the General channel of the Help Desk team.