> For the complete documentation index, see [llms.txt](https://docs.thousandeyes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thousandeyes.com/product-documentation/integration-guides/custom-webhook-examples/microsoft-teams-for-alert-notifs.md).

# Microsoft Teams for Alert Notifications

Use this integration when your network operations team coordinates incident response in Microsoft Teams. It sends ThousandEyes alert notifications to a channel that responders already monitor. Each notification shows whether an alert was triggered or cleared, its severity, and a link to the alert in ThousandEyes. This shared view helps responders track alert status without relying on a separate email inbox.

This example uses a standard Microsoft Teams channel, an incoming webhook workflow that accepts requests from outside Microsoft Teams, and a custom webhook operation in ThousandEyes. Microsoft manages the Teams setup steps and interface. Use the linked Microsoft documentation if the options in Teams differ from this example.

## Prerequisites

| System                    | Requirement                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Microsoft Teams           | Your account can access the target team and post in its channel. If you need a new team, your organization must allow you to create one. See [Create a team from scratch in Microsoft Teams](https://support.microsoft.com/en-us/teams/teams-channels/create-a-team-from-scratch-in-microsoft-teams).                                                            |
| Microsoft Teams channel   | This procedure uses a standard channel. By default, team owners and members can create standard channels, but an admin can limit this permission. See [Standard, private, or shared channels in Microsoft Teams](https://support.microsoft.com/en-us/teams/teams-channels/standard-private-or-shared-channels-in-microsoft-teams).                               |
| Microsoft Teams Workflows | Your account can use the Workflows app. A Teams admin must enable the app and allow it for your account. See [Create flows in Microsoft Teams](https://learn.microsoft.com/en-us/power-automate/teams/teams-app-create) and [Manage app permission policies in Microsoft Teams](https://learn.microsoft.com/en-us/microsoftteams/teams-app-permission-policies). |
| ThousandEyes              | Your role can create integrations and assign alert rules in the ThousandEyes platform.                                                                                                                                                                                                                                                                           |

## Creating a Microsoft Teams Workflow

1. Choose an existing standard channel for ThousandEyes alerts. If you need a new team, follow [Create a team from scratch in Microsoft Teams](https://support.microsoft.com/en-us/teams/teams-channels/create-a-team-from-scratch-in-microsoft-teams).
2. Confirm that the account that owns the workflow can access the team and post in the channel.
3. Follow [Send messages in Teams using incoming webhooks](https://support.microsoft.com/en-us/workflows/send-messages-in-teams-using-incoming-webhooks) to create a channel webhook. Use values like these for a ThousandEyes workflow:

   | Microsoft Teams Setting      | Example Value                        |
   | ---------------------------- | ------------------------------------ |
   | Template                     | **Send webhook alerts to a channel** |
   | Workflow name                | `ThousandEyes alert notifications`   |
   | Who can trigger the workflow | **Anyone**                           |
   | Team                         | `Network Operations`                 |
   | Channel                      | `ThousandEyes Alerts`                |

   ThousandEyes sends webhook requests without a Microsoft identity. If you create the workflow from scratch, select **Anyone** for the **When a Teams webhook request is received** trigger.
4. Save the workflow and copy its webhook URL. Microsoft also explains how to retrieve the URL later in [Send messages in Teams using incoming webhooks](https://support.microsoft.com/en-us/workflows/send-messages-in-teams-using-incoming-webhooks).
5. Store the workflow URL securely. You use it to configure the ThousandEyes connector and operation.

The **Anyone** option does not require Microsoft authentication. Anyone who has the workflow URL can send requests to it, so do not share the URL or include it in tickets, chat messages, or source control.

Microsoft Teams workflows belong to individual owners, not to a team or channel. Use an organization-managed account or add a co-owner so the workflow continues if the original owner leaves. See [Create and send messages](https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using#limitations).

## Creating the ThousandEyes Integration

In ThousandEyes, a custom webhook setup has two parts:

* A generic connector, which stores the workflow host in the **Target** field.
* A custom webhook operation, which stores the workflow path, query parameters, headers, and body.

Split the Microsoft Teams workflow URL into these fields before you create the connector and operation. Decode percent-encoded characters when you move query parameter values into the JSON object. For example, use `/triggers/manual/run` instead of `%2Ftriggers%2Fmanual%2Frun` for the `sp` value.

For example, if your workflow URL is:

```
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
```

Use the following ThousandEyes values:

| ThousandEyes Field       | Value                                                                  |
| ------------------------ | ---------------------------------------------------------------------- |
| **Target**               | `https://prod-81.westus.logic.azure.com:443`                           |
| **Path**                 | `/workflows/122c49e2573a46fc9c211efeb3dd/triggers/manual/paths/invoke` |
| **URL Query Parameters** | See the JSON example below.                                            |

```
{
  "api-version": "2016-06-01",
  "sp": "/triggers/manual/run",
  "sv": "1.0",
  "sig": "abcdefghijklmnopq"
}
```

Use the **Integration Templates** flow if you don't already have a generic connector for Microsoft Teams. If you already have the connector, use the **Operations** flow instead.

### Creating a Connector and Operation from the Integration Template

1. In the ThousandEyes platform, go to **Manage > Integrations**.
2. Select the **Integrations 2.0** tab.
3. Select the **Integration Templates** tab.
4. Select the **Custom Webhook** template.
5. Set up the generic connector:
   * **Name**: Type a name that helps you identify the Microsoft Teams channel or workflow.
   * **Target**: Type the scheme, host, and port from the Microsoft Teams workflow URL.
   * **Auth Type**: Select **None** unless your organization has configured a separate authentication requirement for the target.
6. Select **Save & Assign Operation**.
7. Set up the custom webhook operation:

   * **Operation Name**: Type a name that helps you identify the alert-notification operation.
   * **Preset Configurations**: Select **Microsoft Teams** if you want ThousandEyes to populate a starting Adaptive Card payload and the `Content-Type: application/json` header. Selecting a preset replaces any values already in the operation fields.
   * **Path**: Type the path from the Microsoft Teams workflow URL.
   * **Custom Headers**: If you don't use the **Microsoft Teams** preset, add a header with **Content-Type** as the name and `application/json` as the value.
   * **URL Query Parameters**: Paste a JSON object that contains the query parameters from the Microsoft Teams workflow URL. Use `/triggers/manual/run` for the `sp` value, not `%2Ftriggers%2Fmanual%2Frun`.
   * **Body**: Paste the payload shown below. Microsoft Teams workflows support Adaptive Cards v1.4.

   Replace `<account-group-name>` with the account group name that you want the card to display before you save the operation.

```
{
 "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": "<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?__a={{alert.rule.account.id}}&tab=active&alertId={{alert.id}}{{else}}https://app.thousandeyes.com/alerts/list?__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
     }
    ]
   }
  }
 ]
}
```

#### Open this Alert Button Block

The `Action.OpenUrl` block in the **Body** payload creates the **Open this Alert** button. The `title` property controls the button label that appears in Microsoft Teams.

```json
{
  "type": "ActionSet",
  "actions": [
    {
      "type": "Action.OpenUrl",
      "title": "Open this Alert",
      "url": "{{#eq type.id 2}}https://app.thousandeyes.com/alerts/list?__a={{alert.rule.account.id}}&tab=active&alertId={{alert.id}}{{else}}https://app.thousandeyes.com/alerts/list?__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
}
```

The URL expression sends you to the relevant alert:

* `{{#eq type.id 2}}` sends triggered alerts to **Active Alerts** with `tab=active`.
* `{{else}}` sends cleared alerts to **Alerts History** with `tab=history`.
* `{{alert.rule.account.id}}` selects the account group, and `{{alert.id}}` filters the list to the alert from the notification.

Alternatively, use the [Adaptive Card Designer](https://adaptivecards.io/designer/) to customize your card, and then paste that code in the **Body** field. When you use the designer, nest the Adaptive Card object inside the attachment's `content` object.

8. Select **Test** to verify that the new webhook works.
   * A successful test returns a **Testing completed successfully!** message.
   * If the test fails:
     * Verify that the connector **Target**, operation **Path**, and operation **URL Query Parameters** match the Microsoft Teams workflow URL from [Creating a Microsoft Teams Workflow](#creating-a-microsoft-teams-workflow).
     * Verify that the `sp` query parameter uses `/triggers/manual/run`.
     * Verify that the operation includes a **Content-Type** header with `application/json` as the value.
     * If the test still fails, contact ThousandEyes Support.
9. Select **Save Integration**.
10. Apply the webhook to your existing alert rules using the resulting **Manage Alert Rules** panel.

### Creating an Operation for an Existing Connector

If you already have a generic connector for the Microsoft Teams workflow host, create only the custom webhook operation:

1. In the ThousandEyes platform, go to **Manage > Integrations**.
2. Select the **Integrations 2.0** tab.
3. Select the **Operations** tab.
4. Select **New Operation**.
5. Select **Custom Webhook**.
6. Fill out the operation fields using the guidance in [Creating a Connector and Operation from the Integration Template](#creating-a-connector-and-operation-from-the-integration-template).
7. Save the operation and assign it to the generic connector that contains the Microsoft Teams workflow target.
8. Use **Manage Alert Rules** to assign the operation to the alert rules that should send notifications to Microsoft Teams.

### Receiving Alert Cards

If you use the payload in this article, including the [Open this Alert button block](#open-this-alert-button-block), the webhook sends an Adaptive Card with the account group, rule name, severity, and alert ID.

| Alert State | Card Behavior                                                                                                   |
| ----------- | --------------------------------------------------------------------------------------------------------------- |
| Triggered   | The title is red. **Open this alert** opens the **Active Alerts** screen for the account group and alert ID.    |
| Cleared     | The title is green. **Open this alert** opens the **Alerts History** screen for the account group and alert ID. |

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