Destination: Microsoft Teams Webhook

Hi,

as promised in the community talk, pls find below the Steps to configure a custom Webhook destination to push Alarms into a Microsoft Teams Channel.

Add webhook in Teams:

  • on a Teams channel add a “Connector” ("right mouse click “Connectors”)
  • add “Incoming Webhook” (Send data from a service to your Office 365 group in real time.)
  • configure/create “Incoming Webhook” (assign a name) this will create an URL something like https://outlook.office.com/webhook/xxxxxxxxxxxxx

Add destination in Opendistro:

  • create destination in Alerting / Destination
    • Type : Custom Webhook
    • Define endpoint by URL: → use the URL created by the webhook setup in Teams
  • create/edit Trigger:
    • as destination choose the Custom Webhook
    • as Message Info use the format for “cards” available in Microsoft Teams

example of Message Info / Microsoft Teams card with Mustache template

{
    "@type": "MessageCard",
    "@context": "http://schema.org/extensions",
    "themeColor": "0076D7",
    "summary": "Larry Bryant created a new task",
    "sections": [{
        "activityTitle": "OpenDistro Alert",
        "activitySubtitle": "Trigger: {{ctx.trigger.name}}",
        "activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
        "facts": [{
            "name": "Period start",
            "value": "{{ctx.periodStart}}"
        }, {
            "name": "Period end",
            "value": "{{ctx.periodEnd}}"
        }, {
            "name": "Error",
            "value": "{{ctx.error}}"
        }, {
            "name": "Raw",
            "value": "{{ctx}}"
        }],
        "markdown": true
    }]
}

Detailed documentation about Webhooks in Teams:

Card Reference for Message Info:

Feel free to collaborate and/or add to official documentation.

Regards,
Andreas

3 Likes