Assign Adaptive Card to multiple Teams users
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.
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.
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.