Adaptive Card Responses in Teams using Power Automate

Isaac Stephens, 25 February 2020

image

Power Automate recently released two new actions for Microsoft Teams. These actions allow you to post an Adaptive Card to a User or to a Team and wait for a response. Actions generally just run without any human interaction; however, these new actions bring in a new level of Human – Flow interaction with the action holding until a reply is received from a User. This essentially acts as a second trigger during your flow.

image

To send and wait for a reply from an Adaptive Card go into Power Automate and after your trigger add the Action “Post an Adaptive Card to a Teams user and wait for a response” there is also “Post an Adaptive Card to a Teams channel and wait for a response” but we will not be using this one in this example.
 
Once it has loaded you will see it requires a Recipient. In this section you can add the recipient you wish to receive the Adaptive Card. You can either hardcode this in or use a dynamic value from a previous step / trigger. For testing, I will write in the user’s email address I want to use, which allows me to use the Flow button trigger so I can test my Flow quickly.

Once testing is done you can swap it with the dynamic value from the correct trigger/action, such as a Power Apps button, which you could pass through the user details as a parameter. Note: It may seem like you can add multiple recipients but at the moment this seems to break the Flow, so currently you can only add one recipient per call.

The next step is to click on the ‘Create Adaptive Card Editor’ button which will pop open the built in editor.

image

For more information on how to use this Adaptive Card designer refer to Microsoft adaptivecards.io which contains many samples and full documentation. Once you have decided what you want to create hit save Adaptive Card at the top and the editor will close and take you back to the Flow screen. For my example I have created a feedback card that asks for a rating and comment. Each input field needs a unique ID and these are the IDs that you will refer to back in your Flow.

Now that you have created your Adaptive Card you can use the input fields as Dynamic values in your subsequent actions. In this example I will just send back the user’s choice to the user in another Adaptive Card. This one will not be interactive so will not need to use the ‘wait for reply’ action. Instead we will use ‘Post your own adaptive card as the Flow bot to a user’ action which only asks for the recipient and then has an input box for the Adaptive Card JSON.

image

As shown above I have used three dynamic variables; email, rating, comment. The first one is the email of the user it sent the Questionnaire to, the second is the rating value inputted by the user, and the third is the comment value inputted by the user. As you can see the ID you use when creating the Adaptive Card will be the name of the Dynamic Variable in Flow, so make sure to give it a relevant name!

When you start to implement this remember that it is currently in Preview. This means that there is no guarantee this will ever be fully released and that you are not meant to use this in a production environment. However, this does not stop you from playing around and learning how to use it for when it comes out of Preview and can be used in your Production environment.