Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

webhook flow writes to MS Team channel with adaptive card not working

Like (1) ShareShare
ReportReport
Posted on 5 Sep 2024 21:14:59 by 16
Hello,
 
I'm trying to build a flow with webhook trigger that takes some data in the body and displays it on an adaptive card posted to a teams channel, but it never seems to work ☹️
 
I tried copying some sample from: Samples and Templates | Adaptive Cards
and pasting that into payload of webhook call but keeps failing with the following error:
 
The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body']?['attachments']' is of type 'Null'. The result must be a valid array.
 
Also how can I use the template & data JSON from the samples in adaptivecards.io website, can I setup a template adaptive card in the flow and just pass the data as payload to the webhook or does it need the full adaptive card definition containing the data in one JSON code snippet?
 
  • ChrisKellerMicrostar Profile Picture
    2 on 03 Apr 2025 at 16:16:34
    webhook flow writes to MS Team channel with adaptive card not working
    Possibly too late for the OP, but I was struggling with the same thing, and have found a satisfactory solution. The key is doing the data binding in Power Automate.
     
    In my example, I want to send a title and description in the webhook POST request, and have the adaptive card template stored as part of the workflow.
     
    I started with the PA template "Post to a channel when a webhook request is received." That gives you a webhook trigger, a "send each adaptive card" step for the attachments, and within that a "post card in chat or channel" step. In the body of the "post card" step, set up the sender and channel the way you want, and the "Adaptive Card" body can be the template JSON, e.g. from the sample site. However, you can't rely on the regular adaptive card replacement tokens, ${}! You must use PA dynamic expressions to bind the data.
    {
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.5",
        "type": "AdaptiveCard",
        "body": [
            {
                "type": "TextBlock",
                "text": "@{items('Send_each_adaptive_card')?['data/title']}",
                "wrap": true
            },
            {
                "type": "TextBlock",
                "text": "@{items('Send_each_adaptive_card')?['data/description']}",
                "wrap": true
            }
        ]
    }
    Now in the POST request body, the webhook step still expects us to use the adaptive cards schema, so we have to keep parts of that, but we can add data alongside the usual elements.
    {
        "type": "message",
        "attachments": [
            {
                "contentType": "application/vnd.microsoft.card.adaptive",
                "contentUrl": null,
                "content": {},
                "data": {
                    "title": "The daily news",
                    "description": "Something you should know"
                }
            }
        ]
    }
    And that seems to work!
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Building Flows

#1
David_MA Profile Picture

David_MA 351 Super User 2025 Season 1

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 290 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 278

Overall leaderboard
Loading started