Assign Adaptive Card to multiple Teams users
Table of contents:
I’ve been asked that question multiple times – how to assign a single Adaptive Card to multiple Microsoft Teams users and then collect responses. The point is, that action “Post an Adaptive Card to Teams user and wait for response” lets us to collect just a single response at a time. So how can we do it?
There are two possible approaches – assign multiple cards in parallel or sequentially. Then of course wait for all responses or wait just for first. But let’s focus on two scenarios – wait for all responses in parallel and sequential order.
Sequential scenario
This scenario seems to be quite easy. We need to prepare a list of assignees, then convert it into array, finally use “Apply to each” loop on that array. In each run, use action, to send Adaptive Card to a user and wait for the response. Once the response is collected, process other steps of logic and then move to another assignee.
Parallel scenario
If number of assignees is fixed, you could try to create a fixed workflow too using parallel branches. Simply, in each branch assign card to a single user and wait for their response. Once all responses are collected, workflow will move out from parallel branch.
What I do like more however is a more generic approach. Watch the video below to understand what I mean. You can watch how I created the solution and how it works, so you can build it yourself 🙂
The main piece to understand in the more generic approach is that it uses:
- Child Flow to assign each individual assignee an Adaptive Card,
- Database to register outcomes from completed Adaptive Cards,
- Set of workflows that control the overall business flow
The idea is following:
- Main workflow prepares a list of approvers and defines Adaptive Card contents;
- In the loop it triggers Child Flow, passing it assignee details and Adaptive Card contents;
- Child Flow process input data, responds to parent flow (so that it doesn’t wait for Child to be completed), sends Adaptive Card to a user and waits for response. Once response is collected, it saves outcome in database.
- For each saved response another flow is triggered, that checks if all required Adaptive Cards are completed so that the process can simply end. Once that’s true, it validates if general outcome is Approved or Rejected to set workflow outcome.
Database that is used can be either CDS or CDS Lite. It can even be SharePoint. Point is, that it is needed, because the responses are collected asynchronously so there’s a need for a storage, that will keep status of how the process runs.
If you’d like to learn more about my approach please leave a comment below.
Pingback: Last action hero with adaptive cards for cloud demo system ES5 | SAP Blogs
Kevin McCarron
Wow Tom this is fantastic. Extremely creative and thoughtfully constructed. These posts have a tremendous amount of value!
Tomasz Poszytek
Thank you a ton! 🙂
Alex
Hi Tomazh. Trying to reproduce 1st scenario with a sequential execution and faced a problem, that after posting action no output is available to process the reply from adaptive card. When i do a similar thing outside of for each loop for one post action, everything is OK.
Can you suggent something?
Tomasz Poszytek
Yes, this is a known bug. You need to use expression to get data from the card. Simply use ‘Compose’ action and preview what body(‘Name_of_your_Adaptive_Card_action’) returns. Then simply use: body(‘Name_of_your_Adaptive_Card_action’)?[‘data’] or ‘submitActionId’ to get what you need.
Mohamed Sithick
Hi Tomasz,
I hope you doing well. I need your guidance. How to create universal actionable adaptive card for serviceNow. Please provide your step by steps guidance. i’m waiting for your reply. Thanks
Tomasz Poszytek
Hey, please send me an inquiry through the contact form, thanks!
Shifa Momin
Hi All,
I have created a flow to send adaptive cards to multiple user and wait for the response and the flow is sending cards but problem is adaptive cards are showing up sequentially. Once the first user provides their response, the Flow will continue by sending the same card to the second user, then it will wait for that user to respond, and so on.
However if I change the concurrency control I’ll have maximum 50 parallel branches. But what should be the approach if I need to get response from more than 50 users???
Tomasz Poszytek
Hey, in this case I would rather recommend to use the simple “Post adaptive card” action, without waiting, and then to build another flow that is triggered with the “when someone responds to an adaptive card” trigger. Learn more here: https://youtu.be/2ZHv0l_6W5Q?si=NbTPlxi6mYr2QLaI