Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Send an Adaptive Card to Teams

(2) ShareShare
ReportReport
Posted on by 252
Hi All,
 
I am looking to post an Adaptive card to a User directly from Powerapps.  I have included the Teams connector in my app and there is an option PostCardtoConversation.   I have found the below syntax:
Which gives me what I need, but I am unsure as to what format the JSON needs to be in the DynamicPostCardRequest.  Any help would be appreciated.
 
 
Categories:
  • Verified answer
    Skybluekid Profile Picture
    Skybluekid 252 on at
    Send an Adaptive Card to Teams
    I have figured the solution, as below:
     
    UpdateContext(varChat:
                          MicrosoftTeams.CreateChat("[Email Address",{topic:""})});
    UpdateContext({Object:{
        type: "AdaptiveCard",
        version: "1.5",
        body: [
            {
                type: "TextBlock",
                text: "Hello User!",
                wrap: true
            }
        ]
    };
    UpdateContext({Object2:JSON(Object)});
     
    MicrosoftTeams.PostCardToConversation(
        "User",
        "Group Chat",
        ParseJSON(
            JSON(
                {recipient : varChat.id,
                messageBody: Object2},JSONFormat.Compact)))
     
     
  • Skybluekid Profile Picture
    Skybluekid 252 on at
    Send an Adaptive Card to Teams
    Hi miztrz,
     
    Thank you for the reply. We applying I am getting the error as shown:
    any ideas?
     
  • Suggested answer
    miztrz Profile Picture
    miztrz 4 on at
    Send an Adaptive Card to Teams

    Hi! You can design your card using the Adaptive Cards Designer.

    • Extract the JSON payload and format it as a string in Power Apps. For example:
    AdaptiveCardText = "{ 
     \"type\": \"AdaptiveCard\",
     \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
     \"version\": \"1.3\",
     \"body\": [
       {
         \"type\": \"TextBlock\",
         \"text\": \"Hello, User!\",
         \"wrap\": true,
         \"size\": \"Large\",
         \"weight\": \"Bolder\"
       }
     ]
    }"
    • Use the PostCardToConversation function in your app, combining the recipient details and the Adaptive Card payload, like the below example:
    MicrosoftTeams.PostCardToConversation(
     "Flow bot",
     "Chat",
     ParseJSON(
       JSON(
         {
           recipient: {
             userId: "your-user-id", // Replace with the user's actual ID
             tenantId: "your-tenant-id" // Replace with your tenant ID
           },
           messageBody: AdaptiveCardText // Reference to your Adaptive Card JSON string
         },
         JSONFormat.Compact
       )
     )
    )
    • Replace "your-user-id" and "your-tenant-id" with the actual values

    Check out this blog for more details! Let me know if that answers your question. :)

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard