I have a functioning webhook to a Teams channel to which I can successfully post messages. I am now trying to post an adaptive card to the webhook. Using Postman and performing a Post to https://outlook.office.com/webhook/xyz, with Content-Type
set to application/json
in the header and the following adaptive card set in the body.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"speak": "Nothing to say.",
"body": [
{
"type": "TextBlock",
"text": "Hello Teams' user"
}
]
}
With this I receive a HTTP 400 Bad Request and Summary or Text is required message. Does anyone know if Teams webhooks support Adaptive Cards yet or if this is an unsupported task currently?
Select New Step. Search for Microsoft Teams, and then select Post an adaptive card to a Teams channel and wait for a response as the action. Select the Team and the Channel to which you'd like to post the card. Paste this JSON into the Message box.
Media elements are currently not supported in Adaptive Card on the Teams platform.
Adaptive Cards are actionable snippets of content that you can add to a conversation through a bot or message extension. Using text, graphics, and buttons, these cards provide rich communication to your audience. The Adaptive Card framework is used across many Microsoft products, including Teams.
The webhook is available in the Teams channel. You can create and send actionable messages through Incoming Webhook or Office 365 Connector.
I'm using axios to send an Adaptive Card to a Teams Connector and I was getting this same error. In my case, I was able to resolve the issue by wrapping the card as an "attachment" to the message protocol shown in this link (syntax copied here for reference).
https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-adaptive-cards-using-an-incoming-webhook
{
"type":"message",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"contentUrl":null,
"content":{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"type":"AdaptiveCard",
"version":"1.4",
"body":[
{
"type": "TextBlock",
"text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
}
]
}
}
]
}
By sending the above JSON as the request body (data
argument for axios), I successfully got the Adaptive Card to show up in my Teams Channel.
As you can see, the value of "content"
is the Adaptive Card structure. The Adaptive Card follows the documented syntax, found here:
https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/getting-started
https://docs.microsoft.com/en-us/answers/questions/400502/adaptive-cards-with-incoming-webhooks-in-microsoft.html
But ultimately, I found it easier to work with this "Designer" https://www.adaptivecards.io/designer/ which provides a WYSIWYG interface.
I am sending the request to a Connector that I created in Teams by following the instructions found here:
https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#create-incoming-webhook-1
And now it responds with 200 OK and shows up in the Channel!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With