Microsoft Teams for Workflows

Your Dynatrace environment can integrate with Microsoft Teams channels using Microsoft Teams for Workflow Microsoft Teams for Workflows in automation workflows.

Deprecation

Due to the retirement of Office 365 connectors within Microsoft Teams, Office 365 webhooks will stop working after December 31, 2024.

To continue sending messages from Dynatrace to Microsoft Teams, follow the steps in the Migrating from incoming webhooks to Microsoft Power Automate section.

Integrate Microsoft Teams with Dynatrace workflows

Step 1 Install Microsoft Teams for Workflows

To use Microsoft Teams workflow actions, you first need to install Microsoft Teams for Workflows Microsoft Teams for Workflows from Dynatrace Hub.

  1. In Dynatrace Hub Hub, select Microsoft Teams for Workflows.
  2. Select Install.

After you install Microsoft Teams for Workflows, you need to perform some initial steps to set up the connection between Microsoft Teams and your Dynatrace environment.

Step 2 Create a Microsoft Power Automate webhook

Dynatrace needs a Microsoft Power Automate webhook for the Teams channel where you want to send notifications. The messages in Teams are sent under the name of the user who created the webhook.

To create a Microsoft Power Automate webhook

  1. In Microsoft Teams, open the context menu of the required channel and select Workflows.
  2. Search for Post to a channel when a webhook request is received and select the entry.
  3. Complete the details and select Next.
  4. Select Add workflow.
  5. Copy the generated URL. You'll need it in the next steps.

Step 3 Allow Microsoft Teams for outbound connections

Allow outbound connections for the Microsoft Teams instance that is used to receive messages.

  1. In Dynatrace, go to Settings Settings > Preferences > Limit outbound connections.

  2. Select Add item and add the domain of your publicly accessible Microsoft Power Automate webhook.

    For example, *.logic.azure.com can be used as a domain on the Limit outbound connections page to allow sending messages to all Microsoft Teams instances. The specific domain can also be inferred when creating the webhook.

  3. Select Save changes.

Step 4 Insert the webhook URL

Insert the URL as Webhook URL in the Microsoft Teams for Workflows app settings.

  1. Go to Settings > Dynatrace Apps > Microsoft Teams Connections.
  2. Open or create (Add item) a connection configuration.
  3. In Webhook URL on the configuration page for the connection, paste the URL you generated in the previous procedure. If you are adding a new connection, you also need to give the connection a name.
  4. Select Save changes.

Use workflows with Microsoft Teams

The workflow action can be used to send Markdown-formatted cards or AdaptiveCard format.

Inputs

  • Connection: the Webhook connection used for sending messages.
  • Select Template: a pre-defined AdaptiveCard that will be used as a message.
  • Message: Markdown-formatted text or the output of the AdaptiveCard designer or input from another action producing such a format.

Input examples

  • Connection: select any connection from the dropdown list (for example, dynatrace-notifications-sandbox).

  • Message: see the examples in the following table.

    Input type

    Sample input

    Markdown

    **Hello World**
    This is Markdown-formatted text!

    AdaptiveCard

    {
    "type": "AdaptiveCard",
    "actions": [],
    "body": [
    {
    "type": "TextBlock",
    "size": "Medium",
    "weight": "Bolder",
    "text": "Hello World"
    }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4"
    }

    Automation expression

    {{ result("build_ms_teams_message_action") }}
  • Interactions

    Select Send test message (under the input field) to send a test message. However, if the message contains any automation expression, the expression will not be processed but sent as is.

  • Output: The action does not have any output besides logs.

  • Log output examples

    • Successful:
      [INFO] POST https://xxxxxxx.webhook.office.com/*** called successfully
      [INFO] Message has been posted successfully
    • Error:
      [ERROR] Received unexpected HTTP Response from API: 503 Service Unavailable
      [ERROR] POST https://xxxxxxxx.webhook.office.com/*** Unable to communicate with the Teams API: Encountered unknown HTTP status code 503 - Service Unavailable

Example 1: On demand trigger

To create a workflow that sends a message on demand to a Microsoft Teams channel

  1. Go to Workflows Workflows and select Add to create a new workflow.

  2. In the side panel, select On demand trigger.

  3. On the trigger node, select Add to browse available actions.

  4. In the side panel, search the actions for Microsoft Teams for Workflows and select Send message.

  5. In the side panel

    • Select a preconfigured Microsoft Teams Connection.
    • Type or paste the Message to send to the channel.
  6. Select Save.

    If you Run the workflow successfully:

    • The Message you defined is sent to the selected Microsoft Teams channel.
    • The Detail tab in the side panel displays the State value Success.

Example 2: Fixed time trigger

To create a workflow that sends a daily reminder at a fixed time to a Microsoft Teams channel, you just need to slightly modify the trigger in the previous procedure.

With the previous workflow displayed in your editor

  1. Select the current trigger (On demand trigger).

  2. In the side panel, select Change trigger.

  3. In Select a trigger, select Fixed time trigger.

  4. Define when to send the message.

    • Set Run at to the time of day at which to send the message.
    • Set Rule to Every working day.
  5. Select Save.

    If you Run the workflow successfully:

    • The Message you defined is scheduled to be sent to the selected Microsoft Teams channel at the specified time every day.
    • The Detail tab in the side panel displays the State value Success.

Example 3: AdaptiveCard format

If you use the previous example but paste the following into Message, the message "Daily reminder test - AdaptiveCard format" with the defined formatting will be sent out daily at the time defined in the trigger.

{
"type": "AdaptiveCard",
"actions": [],
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Daily reminder test - AdaptiveCard format"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4"
}

Example 4: Preconfigured templates

If you're triggering a workflow using a Davis problem or a security notification, you might want to consider the templates that come with the Microsoft Teams for Workflows action.

To use a template, you need to have an Event trigger targeting event.kind == "SECURITY_EVENT", or a Davis problem trigger. For details, see the trigger documentation.

Once the connection is set, you can choose the appropriate template from the list. The template's content will be copied in the message box, ready to be used as is, or modified to suit your needs.

The templates can heavily use the Jinja template syntax. For this reason, we recommend that you familiarize yourself with Jinja before making any changes. Incorrect Jinja expressions can lead to errors when running an action. For example, see "Error evaluating input" when executing the action in the Troubleshooting section.

Migrate from incoming webhooks to Microsoft Power Automate

  1. Identify all connections to be migrated.

    When configuring actions in the Workflows app, a warning is displayed for all actions that use an Office 365 webhook.

    Additionally, all executions that use an Office 365 webhook connection produce a warning log entry.

  2. Create a Microsoft Power Automate webhook.

  3. Add the new webhook domain to outbound connections.

  4. In existing connections, replace the webhook URL.

  5. optional Delete the Office 365 webhook in MS Teams.

  6. Once all Office 365 webhooks are replaced, delete the outbound connection for the Office 365 webhook domain.

Troubleshooting

The following are solutions to problems some people have.