Using Teams workflows to automatically post an Adaptive Card in a channel

Vanja Stojanović 45 Reputation points
2024-07-24T08:03:32.78+00:00

Hi team!

My situation is as follows: I set up a python application which will dynamically generate a JSON file upon some trigger, the JSON template looks like the following:

{
  "type": "AdaptiveCard",
  "attachments": [       
	{         
		"$$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "contentType": "AdaptiveCard",
        "content": {

        },
        "version": "1.5",
        "body": [
          {
            "type": "TextBlock",
            "text": "${releaseTitle}",
            "weight": "bolder",
          	"size": "large"
          },
          {
            "type": "TextBlock",
            "text": "${description}",
            "wrap": true
          }
        ] 
      }
    ]
}

The JSON then gets templated correctly (I have triple checked the output, the double $ sign is to escape the $ sign itself in python templating). This is then sent as the body of a POST request to a Teams webhook, which has the following flow:User's image

When I activate the request, it is successfully received and triggered, only that the card, when posted, is empty, without the text block specified in the request. Is there a different way of achieving the posting of a dynamically generated adaptive card?

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,311 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,341 questions
0 comments No comments
{count} votes

Accepted answer
  1. LiweiTian-MSFT 20,720 Reputation points Microsoft Vendor
    2024-07-25T01:32:34.2133333+00:00

    Hi @Vanja Stojanović

    Teams tag is mainly focused on the general issue of Microsoft Teams troubleshooting. According to your description, your question is related to Teams Development which is not in our support scope. To better help you solve your problem, please add the Teams Development tag to your post. The following suggestion is just for your reference:

    Please make sure the Json format is correct. Please include the body field and version field in the Content field.

    Use the incoming webhook to send adaptive cards. The Json format should be as follows:

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

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.