# Microsoft Teams for Alert Notifications

This article shows you how to receive ThousandEyes alert notifications in a Microsoft Teams channel using custom webhooks.

MS Teams uses MS Workflows to connect with third parties, such as ThousandEyes.

To receive alert notifications in a Microsoft Teams channel, set up a new [workflow within Microsoft Teams](#steps-within-microsoft-teams) and a [custom webhook within ThousandEyes](#steps-within-thousandeyes).

## Prerequisites

For Microsoft Teams:

* You must have permissions to *Create a channel*, *Manage lists*, *Edit items*, and *Post messages in a channel*.

## Steps Within Microsoft Teams

1. Log in to Microsoft Teams.
2. Configure a Teams channel for the custom webhook to use for alerts from ThousandEyes. You can create a new Teams channel or use an existing one.

   a. To create a new channel, click **Add Channel** within the dropdown menu accessible via the ellipsis next to your Team.

   ![Add channel button](/files/7fYj1LnDAjgV5tQQG6T3)

   b. Fill in the fields for the new channel.

   ![Create a channel dialog](/files/Gy6VKuIuFYsdRzfuP6OR)
3. Open your chosen channel and click the ellipsis on the top right to open the menu and click Workflows.

   ![Workflows button in channel menu](/files/UdJh9l9RA3ohe7mGkkhQ)
4. In the search window, type “webhook” to filter options, and click “Post to a channel when a webhook request is received” under **Templates**.

   ![Workflows templates screen](/files/Vwk7rrFk6nLT2Y256Ijz)
5. In the resulting dialog, select what “Connection” the workflow should use. By default, the connection displays the MS Teams user’s email address. You can also elect to use a service account. We recommend using service accounts to ensure continuation of alerts since users can come and go.

   a. To add a service account, click the ellipsis next to the user’s email and click **+ Add new connection**.

   ![Workflow connection options](/files/lrRUJ6XOUMFBtCuThfy1)

   b. Select **Use another account** and enter the relevant credentials.

   c. If you do not want to use a service account, and the user is the correct user, click **Next**.

   ![Completed connection screen](/files/gNVMifugzjleu8CEE015)
6. On the next screen, select the “Team” and “Channel” where the notifications should be posted to.

   * **Note**: If you select a private channel as the target, you need to customize the workflow as an additional step after creating the initial workflow. See [Customizing Workflows for Private Channels](#customizing-workflows-for-private-channels).

   ![Workflow team and channel options](/files/b9ge76aAWAPzTIMMdhKQ)
7. Click **Add workflow** to complete.
8. Once created, you will see a confirmation dialog that includes the URL to send the webhooks to.

   ![Workflow completion screen with webhook URL](/files/aH9J7imlBLBk04keqqMY)

   * This URL is not yet compatible with ThousandEyes. It includes percent-encoded characters that are not supported by ThousandEyes. To fix the URL and make it compatible:
   * Copy and paste the URL into any text editor (you cannot edit the URL within the dialog).
   * Replace the percent-encoded characters with their equivalent characters. For example, for `https://prod-81.westus.logic.azure.com:443/workflows/122c49e2573a46fc9c211efeb3dd/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=abcdefghijklmnopq`, replace the `%2F` with a forward slash `/` to create `https://prod-81.westus.logic.azure.com:443/workflows/122c49e2573a46fc9c211efeb3dd/triggers/manual/paths/invoke?api-version=2016-06-01&sp=/triggers/manual/run&sv=1.0&sig=abcdefghijklmnopq`.
   * If these characters are not changed, you will see an HTTP 401 error on ThousandEyes when you attempt to create the custom webhook.
9. Keep the edited URL somewhere you can later reference for the [Steps Within ThousandEyes](#steps-within-thousandeyes).
10. Click **Done**.

### Retrieving the Workflow URL

1. If you closed the confirmation dialog and lost the link before you could copy it, navigate to the **Workflows** screen by clicking the ellipsis on the lefthand menu of MS Teams and select “Workflows”.

   ![Workflows app in apps menu](/files/zrjSkGx0lqGjASncHODT)
2. In this screen, you will see all the workflows created. Open the relevant workflow.

   ![List of recently completed workflows](/files/kubjCuSwSnpbNLCniIMu)

   ![Workflow details screen](/files/NdyI81hG9CPLZcBPEwNq)
3. Click Edit in the top left.
4. On the edit screen, click "When a Teams webhook request is received".

   * This reveals the HTTP POST URL.

   ![HTTP POST URL on edit screen](/files/Eey81U30dJEftk3a7O4X)

### Customizing Workflows for Private Channels

1. In Teams, open Workflows by clicking the ellipsis from the lefthand menu in MS Teams.

   ![Workflows app in apps menu](/files/2EEsK31MuE1wwVVz3gLG)
2. Select the workflow you just created.

   ![List of recently completed workflows](/files/kubjCuSwSnpbNLCniIMu)
3. Click **Edit**.

   ![Workflow Edit button](/files/43NmhvNYRcgckqUPQRju)
4. Select “Send each adaptive card” then click “Post card in a chat or channel”

   ![Workflow Edit screen](/files/aCVDkbPwn74w5SwYMG7h)
5. Modify the following fields:

   * In **Post as**, select “User”. The user owning the workflow must have access to the channel.
   * Leave **Post in** as “Channel”.
   * Select the **Team** and **Channel**.
   * Do not modify the **Adaptive Card** field.

   ![Edit screen fields](/files/GXLYBNx6Z1Mgo3mG4QIY)
6. Click **Save**.

## Steps Within ThousandEyes

1. In the ThousandEyes platform, navigate to **Manage > Integrations** and click **+ New Integration** in the top right.

   ![New Integration button on Integrations screen](/files/vo8mRotAH91wTn8pVTFx)
2. In the side panel that opens, select **Custom Webhook**.

   ![Custom Webhook button](/files/jU4zJ6D7dmGnzlaE6AgT)
3. Fill in the resulting fields as follows:
   * **Name**: The name should help you to quickly identify this integration.
   * **URL**: Saved in step 9 of [Steps Within Microsoft Teams](#steps-within-microsoft-teams).
   * Do not override with the existing Microsoft Teams **Preset Configuration**. This configuration is no longer supported by Microsoft.
   * **Headers**: Add a Key-Value Pair with “content-type” as the key and “application/json” as the value.
   * Microsoft Teams supports Adaptive Cards v1.4. Paste the payload shown below into the **Body** field to create a simple card.
     * **Note**: Remember to edit the account group name you want to show up on the card in the body text.

```
{
 "type": "message",
 "attachments": [
  {
   "contentType": "application/vnd.microsoft.card.adaptive",
   "contentUrl": **null**,
   "content": {
    "type": "AdaptiveCard",
    "$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "body": [
     {
      "type": "Container",
      "items": [
       {
        "type": "ColumnSet",
        "spacing": "Small",
        "horizontalAlignment": "Left",
        "columns": [
         {
          "type": "Column",
          "width": "auto",
          "items": [
           {
            "type": "Image",
            "url": "https://app.thousandeyes.com/static/images/logo_128x128.png",
            "width": "48px",
            "height": "48px"
           }
          ]
         },
         {
          "type": "Column",
          "width": "stretch",
          "items": [
           {
            "type": "Container",
            "items": [
             {
              "type": "TextBlock",
              "text": "ThousandEyes Alert Notification",
              "wrap": true,
              "horizontalAlignment": "Left",
              "size": "Large",
              "weight": "Bolder",
              "separator": true
             }
            ],
            "horizontalAlignment": "Left",
            "verticalContentAlignment": "Center"
           }
          ],
          "verticalContentAlignment": "Center"
         }
        ]
       }
      ],
      "showBorder": false,
      "horizontalAlignment": "Center",
      "spacing": "None"
     },
     {
      "type": "TextBlock",
      "text": "Alert{{#eq type.id 2}} Triggered{{else}} Cleared{{/eq}}{{#if alert.test}} for {{alert.test.name}}{{/if}}",
      "wrap": true,
      "size": "Large",
      "color": "{{#eq type.id 2}}Attention{{else}}Good{{/eq}}"
     },
     {
      "type": "FactSet",
      "facts": [
       {
        "title": "Account Group",
        "value": "Edit here the Account Group name"
       },
       {
        "title": "Rule Name",
        "value": "{{alert.rule.name}} - {{formatExpression alert.rule.expression}}"
       },
       {
        "title": "Severity",
        "value": "{{alert.severity.display}}"
       }
      ],
      "separator": true
     },
     {
      "type": "FactSet",
      "facts": [
       {
        "title": "Alert ID",
        "value": "{{alert.id}}"
       }
      ],
      "separator": true
     },
     {
      "type": "ActionSet",
      "actions": [
       {
        "type": "Action.OpenUrl",
        "title": "Open this Alert",
        "url": "{{#eq type.id 2}}https://app.thousandeyes.com/alerts/list/v2?__a={{alert.rule.account.id}}&tab=active&alertId={{alert.id}}{{else}}https://app.thousandeyes.com/alerts/list/v2?__a={{alert.rule.account.id}}&tab=history&alertId={{alert.id}}{{/eq}}",
        "tooltip": "Click to open this Alert on ThousandEyes",
        "iconUrl": "https://app.thousandeyes.com/static/images/logo_128x128.png"
       }
      ],
      "separator": true
     }
    ]
   }
  }
 ]
}
```

![Completed fields in the integration](/files/7rBQBQgq4YG4Jh5zycY7)

Alternatively, use [Microsoft’s card editor](https://adaptivecards.io/designer/) to customize your card, then paste that code in the **Body** field. Note that when using Microsoft’s card editor, the Adaptive Card object is nested inside the attachment’s content.

![Microsoft card editor](/files/dkTtmAZzuwMI6Y5Ka0KS)

4. Click **Test** to verify that the new webhook is working.
   * A successful test returns a “Testing completed successfully!” message.
   * If the test fails:
     * Click **Save** to save the integration.
     * Re-open the integration and test it again.
     * If the test still fails, verify that the webhook URL in the ThousandEyes custom webhook matches the Microsoft Teams workflow URL from steps 9 and 10 in [Steps Within Microsoft Teams](#steps-within-microsoft-teams) and that you have added the key-value pair as a Header from step 3, above.
     * If the test still fails, contact ThousandEyes Support.
5. Click **Save**.
6. Apply the webhook to your existing alert rules using the resulting **Manage Alert Rules** side panel.

   ![Manage Alert Rules screen](/files/04vvUcYQVHiEpvCWrTQt)

### Receiving Alert Cards

If you used the code in the **Body** field from step 3 in [Steps Within ThousandEyes](#steps-within-thousandeyes), the resulting webhook will render an Adaptive Card in your chosen MS Teams channel that looks like the following:

* When an alert is triggered:

  * The title text is red, and a link (via the **Open this Alert** button) takes you to the **Active Alerts** screen within the relevant account group, automatically filtered by the alert ID.

  ![Alert triggered adaptive card](/files/dZQhUZPEf4DqKaBCAbpu)

  ![Active Alerts screen showing triggered alert](/files/VrLDIiwPTyuBw0Ik92cQ)
* When an alert is cleared:

  * The title text is green, and a link (via the **Open this Alert** button) takes you to the **Alerts** **History** screen within the relevant account group, automatically filtered by the alert ID.

  ![Alert cleared adaptive card](/files/TT0ByEtQRDtZpQLVz2Lr)

  ![Alerts History screen showing cleared alert](/files/nb43LEYzvDrdfWyrnXib)

For more information on configuring webhooks, see [Custom Webhooks](https://docs.thousandeyes.com/product-documentation/integration-guides/custom-webhooks).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thousandeyes.com/product-documentation/integration-guides/custom-webhook-examples/microsoft-teams-for-alert-notifs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
