Skip to main content

Send notifications to Microsoft Teams

Note

This procedure uses the alert webhook.

You can enable bidirectional communication between Moogsoft Cloud and Microsoft Teams. This integration provides the following features:

  • Moogsoft can notify a specific Teams channel when an incident is generated or updated.

  • Incidents in Moogsoft contain links to their corresponding team channels in Microsoft Teams.

  • Notifications in Microsoft Team channels contain links to their corresponding Moogsoft incidents.

The messages sent by this integration are displayed as adaptive cards. This allows you to customize the functionality and appearance of messages. For a detailed explanation of how Adaptive Cards work, read Adaptive Cards Overview.

Note

The default time limit for using the buttons on each message card is two hours. If no action has been taken after two hours, the process will stop listening and cancel the flow. You can extend this time limit per instance of the flow, but doing so may result in flow failures.

Before you begin

Before you set up your Microsoft Teams integration:

  • Make sure that you have created a new, interactive integration user within Microsoft Teams with a premium Power Automate license. A premium license is required for these instructions to work.

    For information on Power Automate licensing, read Power Automate Pricing.

    Note

    The display name of the integrations user is what will appear in the messages sent by this integration. To change your display name, read this topic from the Microsoft documentation.

  • Make sure that you have created a new integration user in Moogsoft and that you are signed in to Moogsoft as this user. Set the first name of the integration user to "Microsoft" and the last name to "Teams."

    For instructions on creating a new user, read Add one or multiple users.

  • Make sure you have a valid Moogsoft API key that you can copy and paste when needed.

    For instructions on creating an API key, read Manage Moogsoft Cloud API keys.

Configure Microsoft Teams using Power Automate

  1. Sign in to Microsoft Power Automate using the credentials for the integration user you created.

  2. Upload the flow package:

    1. From the left hand menu, click My flows.

    2. Click Import > Import Package (Legacy).

    3. Click Upload and select the Moogsoft Teams Integration Flow package. Wait for the package to finish uploading.

    4. Under the Review Package Content section, click Create as new in the row for "Moogsoft Teams Integration Flow."

    5. In the Import setup window that appears, change the setup type to Create as new.

    6. Click Save.

  3. Create a new connection:

    1. Under Review Package Content > Related resources, click Select during import.

    2. In the Import setup window that appears, click the plus sign (+) next to Create new. This opens up a new page in your browser.

    3. In the new page, click New connection.

    4. Search for the Microsoft Teams connection and select it.

    5. In the pop-up dialog that appears, click Create.

    6. When prompted to pick an account, select the account of the integration user you created.

    7. Confirm that your new connection is listed under the Connections page.

  4. Finish importing the flow package:

    1. In your browser, navigate back to the original Import package page.

    2. Within the Import setup window, select the new connection you just created from the list of connections. If your connection does not appear, refresh the list.

    3. Click Save.

    4. Click Import at the bottom of the page to import the package.

    5. When the package has finished uploading, the following message should appear at the top of the page:

      MSTeamsIntegration_packageimport.png

      Click Open flow. This will take you to a new page in your browser, where you can edit the imported flow.

  5. Add the flow URL:

    1. Within the new page for editing the imported flow, click on the first action in the flow: manual

    2. Copy the HTTP POST URL.

    3. Click the second action in the flow: Initialize variable - Flow URL

    4. In the Value field, paste the HTTP POST URL that you copied.

  6. Add your Moogsoft API key to the flow:

    1. Click the third action in the flow: Initialize variable - WebhookApiKey

    2. In the Value field, paste your Moogsoft API key.

    3. Save the flow.

  7. Activate the flow:

    1. From the left hand menu, navigate back to My flows.

    2. Select Moogsoft Teams Integration Flow from the list of flows.

    3. From the menu bar at the top of the page, click Turn on to activate the flow.

  8. Add the integration user and "Incidents" channel to your teams in Microsoft Teams:

    1. Open Microsoft Teams. From the left-hand menu, navigate to Teams.

    2. Add the integration user to all the teams that you want messages to be posted to.

      For instructions on adding a new user to a team, read this topic from the Microsoft Documentation.

    3. Add a new channel called "Incidents" to all the teams that you want messages to be posted to.

      For instructions on adding a new channel to a team, read this topic from the Microsoft Documentation.

      Note

      "Incidents" must be spelled exactly as shown (case-sensitive), or else the integration will not work. If you want to change the channel name to something else, edit the value of the channel_name variable in the outbound webhook payloads.

Create data catalog and workflow in Moogsoft

Once you have finished configuring the Power Automate flow, you will need to use a data catalog and event workflow to determine the kinds of messages that should be sent to your teams in Microsoft Teams. This section explains how to set up an example catalog and workflow configuration. This example configuration sends messages to different teams in Microsoft Teams based on the Service field value of the affected incidents.

To create the example data catalog and event workflow:

  1. In a separate application such as a text editor, create a new CSV file in the following format. Set the header of the first column to Service and set the header of the second column to team:

    Example: In the sample CSV below, messages related to incidents from service1 will get sent to Team1 in Microsoft Teams.

    Service

    team

    service1

    Team1

    service2

    Team2

    service3

    Team3

    Warning

    All team names specified in the CSV file must be exact, case-sensitive matches to the actual team names in Microsoft Teams. Incorrectly spelled or capitalized team names will cause the integration to fail.

  2. Save the CSV file.

  3. Create a new data catalog in Moogsoft:

    1. Within Moogsoft, navigate to Correlate & Automate > Workflow Engine and click the Enrichment Data Catalogs tab.

    2. Click Add Catalog to create a new data catalog.

    3. Provide a unique name and a description for the data catalog.

    4. Under Upload File, click Select File and upload the CSV file you created.

    5. Click Save.

  4. Create a new event workflow in Moogsoft:

    1. Within Moogsoft, navigate to Correlate & Automate > Workflow Engine and click the Event Workflows tab.

    2. Click Add Workflow to create a new event workflow. To learn more about how to create an event workflow, read Event workflow configuration example.

    3. Provide a unique name and a description for the workflow.

    4. Add a Template Field action to the workflow and configure the fields as follows:

      • Template: ${service}

      • Output Field: Add a new tag called Servicelook.

        The final result should be: tags.Servicelook

    5. From the top right corner of the page, click Save. This allows you to use the new tags.Servicelook tag you created in the remaining workflow actions.

    6. Click Edit.

    7. Add an Extract Substring action to the workflow and configure the fields as follows:

      • Input Field: tags.Servicelook

      • Regex Capture Groups: \["(.+)"\]

      • Output Fields: tags.Servicelook

    8. Add a Query Catalog action to the workflow and configure the fields as follows:

      • Catalog Name: Select the name of the data catalog you created.

      • Lookup Mapping:

        • Field: tags.Servicelook

        • Catalog Field: Service

      • Apply Mapping:

        • Catalog Field: team

        • Field: Add a new tag called team.

          The final result should be: tags.team

        • Default Value: Other

      Note

      For detailed explanations of all the actions used in this workflow, read the topics for each action in the Workflow action reference.

    9. Click Save.

    10. Test the workflow using the Workflow Tester. For instructions on testing a workflow, read Test workflows.

    11. Once the test is successful, click Enable to enable the workflow.

  5. Add tags to incidents:

    1. Navigate to Correlate & Automate > Tags.

    2. Click Edit.

    3. Select Create the Incident and copy the following tags.

    4. In the "Select tags" field, select team.

      Note

      If the team tag does not appear, wait for a new incident to be generated that uses the tag.

    5. Click Save.

Configure outbound webhook in Moogsoft

To create the outbound webhook:

  1. Within Moogsoft, navigate to Integrations > Outbound Integrations > Alert Webhook.

  2. Click Add a Webhook and complete each section according to the following:

    1. Name and Scope:

      1. Under Name, provide a unique name for the webhook.

      2. Within the Filter section, define a filter to trigger the webhook (optional).

        Example filter:

        severity = Critical and $tags.team in ("Team1","Team2","Team3")
    2. CREATE Operation and HTTP Configuration:

      1. Set Request Method to POST:

      2. Set the endpoint URL:

        1. Open Microsoft Power Automate in a new tab of your browser.

        2. Within Power Automate, navigate to My Flows > Moogsoft Teams Integration Flow.

        3. From the menu at the top of the page, click Edit to open the flow.

        4. Click on the first action in the flow: When a HTTP request is received

        5. Copy the HTTP POST URL.

        6. Go back to Moogsoft.

        7. In the URL field, paste the HTTP POST URL that you copied.

      3. Make sure that Authorization is set to "No auth."

    3. Payload Body for CREATE Operation:

      1. Copy and paste the following into the Key/Value Editor box, replacing the default text:

        {
            "incidentID":"$id",
            "severity":"$severity",
            "description":"$description",
            "services": "$services",
            "status":"$status",
            "incidentURL":"$incident_url",
            "payload_type":"New",
            "team_name":"$tags.team",
            "channel_name":"Incidents",
            "assignee":"$assignee"
        }
        
    4. Map the Response Payload: External Name and ID:

      1. Skip this section.

    5. UPDATE Notifications:

      1. Enable update notifications to open up the remaining sections.

      2. The Request Method and URL should be pre-populated with the values entered earlier in section 2 ("CREATE Operation and HTTP Configuration"). Make sure that these values are correct.

      3. Select the conditions that should trigger update notifications.

    6. Payload Body for UPDATE Operation:

      1. Copy and paste the following into the Key/Value Editor box, replacing the default text:

        {
            "incidentID":"$id",
            "severity":"$severity",
            "description":"$description",
            "services": "$services",
            "status":"$status",
            "incidentURL":"$incident_url",
            "payload_type":"Updated",
            "team_name":"$tags.team",
            "channel_name":"Incidents",
            "assignee":"$assignee"
        }
  3. At the top of the page, click Test to test the webhook.

  4. Click Save.

  5. (Optional) If you defined a filter for your webhook, you can create an additional webhook as a catch-all. Messages concerning incidents that do not pass the filter will be sent to a team called "Other":

    1. Open Microsoft Teams. Create a new team called "Other" (must be spelled exactly).

    2. Add the integration user as a member to the team.

    3. Create a new channel under "Other" called "Incidents" (must be spelled exactly).

    4. Open Moogsoft. Navigate to Integrations > Outbound Integrations > Webhook.

    5. At the far right side of the original webhook you created, click on the copy icon:

      MSTeamsIntegration_copywebhook.png
    6. Provide a unique name for the duplicate webhook and click Duplicate.

    7. Click on the duplicate webhook to open it.

    8. Click Edit. Make changes to the webhook in the following sections while leaving everything else the same:

      1. Name and Scope:

        1. Define a Filter that is opposite to the filter of the original webhook.

          For example: If the filter of the original webhook is:

          severity = Critical and $tags.team in ("Team1","Team2","Team3")

          ...then the new filter should be:

          severity = Critical and $tags.team not in ("Team1","Team2","Team3")
      2. Payload Body for CREATE Operation:

        1. Replace the text in the Key/Value Editor box with the following payload:

          {
              "incidentID":"$id",
              "severity":"$severity",
              "description":"$description",
              "services": "$services",
              "status":"$status",
              "incidentURL":"$incident_url",
              "payload_type":"Updated",
              "team_name":"Other",
              "channel_name":"Incidents",
              "assignee":"$assignee"
          }
      3. Payload Body for UPDATE Operation:

        1. Replace the text in the Key/Value Editor box with the following payload:

          {
              "incidentID":"$id",
              "severity":"$severity",
              "description":"$description",
              "services": "$services",
              "status":"$status",
              "incidentURL":"$incident_url",
              "payload_type":"Updated",
              "team_name":"Other",
              "channel_name":"Incidents",
              "assignee":"$assignee"
          }
    9. At the top of the page, click Test to test the webhook.

    10. Click Save.