Adaptive Cards are a flexible way to present information within various host applications while maintaining a consistent appearance. After constructing their content as a JSON-based object, users can post Adaptive Cards across differing platforms while retaining a consistent appearance.
In combination with DocumentsCorePack, Adaptive Cards can be used to post links to generated documents in other applications. In this article, we will demonstrate how to post a generated document in a Microsoft Teams chat.
Step-by-Step: Display a Generated Document in Teams Using Adaptive Cards
Consider a scenario where an official proposal is generated in the back office for a potential client. Instead of manually notifying each sales team member, you can automate this process using Power Automate and Adaptive Cards.
To post a generated document in a Teams chat, we will first need to navigate to Power Automate. In Power Automate, we will construct a manual flow that will create the document, the Adaptive Card, and post the card into a Teams chat.
To begin, create an instant cloud flow and select When a row is selected for a trigger.
Then, set your environment and table name. For this example, our table name will be Contacts.
Next, add a Create document (sync) action from the DocumentsCorePack Connector. Set the ❶ template, ❷ row ID, and ❸ file type under the action’s parameters. Under the advanced parameters, make sure to enable the ❹ Save to SharePoint parameter and set it to “Yes.”
Add another action to the flow, this time from Microsoft Teams, labelled Post card in a chat or channel. Here, you will need to set four parameters: Post As, Post In, Recipient, and Adaptive Card.
❶ Post As: Determines “who” should post to Teams. Set this to Flow bot.
❷ Post In: Determines where the post will be sent to. We will set this to Chat with Flow bot.
❸ Recipient: The receiver of the post. Select who should receive the card.
❹ Adaptive Card: The JSON structure that describes the Adaptive Card. The JSON shown in the screenshot can be found below.
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"body": [
{
"text": "A document has been generated!",
"type": "TextBlock",
"horizontalAlignment": "Center",
"size": "Large",
"weight": "Bolder"
},
{
"text": "Your document can be accessed below:",
"type": "TextBlock"
}
],
"actions": [
{
"title": "View generated document",
"type": "Action.OpenUrl",
"url": "INSERT RETURNVALUE2 FROM CREATE DOC STEP"
}
]
}
You will notice that we are missing the “url” under “actions.” This should be filled in with the Return value 2 output parameter from the Create document step. This parameter will contain the SharePoint link that links to our file.
Our adaptive card in Teams
Once all parameters have been filled in, save your flow. To test it, navigate to a contact record of your choosing and run the flow. You will see the Adaptive Card appear in a chat in Teams. Clicking “View generated document” will open a link to the file.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.