AntoineGa / Seq.App.Teams

Seq application for Microsoft Teams
MIT License
13 stars 10 forks source link

Upgrade to using Adaptive Cards #38

Open tormodfj opened 2 years ago

tormodfj commented 2 years ago

With regards to the following note in the README:

As of 9/19/2019, for some reason you still cannot send AdaptiveCards, you need to use the older MessageCards with Teams Connectors.

This is no longer the case. Adaptive cards are now supported for ordinary Teams webhooks, albeit without templating support. All it takes is to attach the card to a "JSON envelope" of type message, and specifying the attachment content type application/vnd.microsoft.card.adaptive.

To manually test this, use Postman (or similar) to POST an HTTP request with the following raw body to a Teams webhook endpoint:

{
    "type": "message",
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "contentUrl": null,
            "content": {
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "type": "AdaptiveCard",
                "version": "1.3",
                "body": [
                    {
                        "type": "TextBlock",
                        "text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
                    },
                    {
                        "type": "Image",
                        "url": "https://adaptivecards.io/content/cats/1.png"
                    }
                ]
            }
        }
    ]
}

Result:

image

Upgrading to using Adaptive Cards will not only future-proof this app, but arguably make development and maintenance easier since one can use the Adaptive Cards Designer to tinker with and preview card layouts.

MaceWindu commented 1 year ago

For anyone interested in AdaptiveCard support - just released new app for it https://www.nuget.org/packages/Seq.App.Teams.AdaptiveCard/#readme-body-tab