Changes to Teams notification webhook

Microsoft is forcing us to use a workflow to process webhooks for Teams. I found that the current pre-defined webhook template did not work with their new implementation. The workflow element for posting a card did not seem to understand the MessageCard JSON that is in the template. I was able to get it working by changing to the AdaptiveCard schema as described by Microsoft.

A sample card is as follows

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "size": "Large",
            "weight": "Bolder",
            "text": "#{ticket.title}",
            "color": "Accent"
        },
        {
            "type": "TextBlock",
            "text": "#{notification.changes}",
            "wrap": true
        },
        {
            "type": "TextBlock",
            "text": "#{notification.body}",
            "wrap": true
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.OpenUrl",
                    "title": "Ticket##{ticket.number}",
					"url": "#{notification.link}"
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.2"
}

Note: The default MS workflow uses webhook attachments. I did not have time to figure out how that should look, but managed to get the above Adaptive card working with a small customization to the template workflow. Maybe someone else can figure out the attachment concept.

1 Like

Thank you for the insights. I thought it was only our documentation that needs an update.

MS Teams Webhook upcoming changes · Issue #577 · zammad/zammad-admin-documentation (github.com)

With attachments we used this one:

{
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "content": {
                "type": "AdaptiveCard",
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "version": "1.3",
                "body": [
                    {
                        "type": "TextBlock",
                        "text": "#{ticket.title}",
                        "weight": "Bolder",
                        "size": "ExtraLarge",
                        "color": "Warning"
                    },
                    {
                        "type": "TextBlock",
                        "text": "#{notification.message}",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "#{notification.changes}",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "#{notification.body}",
                        "wrap": true,
                        "spacing": "ExtraLarge",
            						"size": "Default"
                    }
                ],
                "actions": [
                    {
                        "type": "Action.OpenUrl",
                        "title": "Ticket ##{ticket.number}",
                        "url": "#{notification.link}",
												"style": "positive",
            						"role": "Button"
                    }
                ]
            }
        }
    ]
}
1 Like

Brilliant. This JSON is much better than mine. Can confirm it works with the default Microsoft Power Automate flow template they provide for this purpose.

For all interested people: Fixes #5267 - Pre-defined webhook for Microsoft Teams needs to be upd… · zammad/zammad@0cb60a2 · GitHub

2 Likes