The Official Definition of an Adaptive Card goes like:
“Adaptive Cards are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange. When delivered to a specific app, the JSON is transformed into native UI that automatically adapts to its surroundings. It helps design and integrate light-weight UI for all major platforms and frameworks.”
The Card Authors can describe their content as a simple JSON object and use it to display data or take input from end users using the card. That content can then be rendered natively inside a Host Application like Microsoft Teams, Outlook etc:
In this article we will see how we can use the Adaptive card designer to create a basic Card and send it out from Power Automate to Microsoft Teams.
We have a SharePoint Document Library that acts as a content repository for Procurement Invoices . Upon the upload of a new invoice, we would need to intimate the Finance Controller directly in this Teams Chat. To achieve this, we will use Power Automate and Send the Notification as an Adaptive Card to the User’s Team Chat.
To start off with we will create a Power Automate that gets triggered when a new document is uploaded in the library.
Now we will add the action “Post adaptive card in a chat or channel”
The content that needs to show up in the Adaptive card has to be written as JSON and added to the Adaptive card field in the above action. We can make use of the Adaptative Card Designer which is an interactive visualized that help us to build the json schema.
As we can see we have the screen divided into multiple layouts with the card controls listed out in the left pane followed by a middle section where the actual card is displayed. In the right pane we have the card structure that shows the hierarchy of elements and the way the controls are nested. To the bottom we have the JSON schema of the card which is where we can add the text details that need to show up in the card as well as style and format the card.
We can drag and drop the elements from the left pane to the card directly and this will create corresponding JSON structure elements in the bottom pane. We can edit the content and style of the created element in the bottom pane.
Note : By default the Version is set to 1.5 , ensure to change it to 1.2 so that it works with Microsoft Teams.
The basic structure of a card is as follows:
So we will copy over the json from the designer and paste it in the Flow action as :
We will add the dynamic content “Link to item” to the JSON so that the adaptive card will have the link to the uploaded document.
Lets upload a document to the Document library which will kickstart the flow and it will post the adaptive card to the teams as shown below:
Thus we saw how we can push an adaptive card to Microsoft Teams via Power Automate to display information to the end user.