cancel
Showing results for 
Search instead for 
Did you mean: 
ShanmugaRaja

Microsoft Power Automate: Post Adaptive cards to a Microsoft Teams for an Approval

Post Adaptive cards to Microsoft Teams for Approval using Power Automate

In this article, we are going to see how to create a flow that posts adaptive cards to a Microsoft Teams channel.

To demonstrate, I have taken a simple scenario of post sick leave request adaptive card to my manager for approval via Microsoft team and based on the approval/reject response the email sent to me. Before we start with flow steps. Let’s know about the adaptive cards and Microsoft Teams connector.

Overview of Adaptive cards:

Adaptive Cards are a platform-agnostic method of sharing and displaying blocks of information without the complexity of customizing CSS or HTML. Adaptive cards in JSON format, with integration that cloud apps and service can openly exchange. When delivered to a specific app, the JSON is transformed into a native UI that automatically adapts to its surroundings. It helps design and integrate lightweight UI for all major platforms and frameworks.

Adaptive cards help you integrate into exiting apps like Outlook actionable message, Window timeline, Microsoft teams, and Bot Framework.

Using Adaptive card designer editor, you can easily configure and design an adaptive card. Each adaptive card has its own page with a title, description, chart, images, buttons, etc.

Once an adaptive card design is completed, copy the actual JSON that you can include in Microsoft power automate.

Microsoft Teams connector:

Before choosing the Microsoft Teams connector, we need to decide whether we are going to post adaptive cards to a Microsoft Teams channel, or to Microsoft team members.

Directing Adaptive cards to Teams members:

  • Post your own adaptive card as the Flow bot to a user: This action posts an adaptive card as a Flow bot to a specific user. In this case, you will need to provide a recipient email address, and the card will show up in the recipient's chat and/or activity feeds during the flow run. There is no requirement for the user to be part of a Teams instance to receive these types of Adaptive Cards. In this case, only the URL button functions by redirecting to the URL that's configured within the flow.

Image_01.jpg

Directing Adaptive cards to Teams channels:

  • Post your own adaptive card as the Flow bot to a channel: This action posts an adaptive card as a Flow bot to a specific Teams channel. In this case, you will be prompted for Teams instance and a channel where the card will be posted. The flow-maker will have to have access to the Teams instance in order to post an adaptive card there. In this case, only URL button functions by redirecting to the URL configured within the flow.

Image_02.jpg

 

  • Post an adaptive card to a Teams channel and wait for a response: This action posts an adaptive card as a specific Teams channel as in the case above. However, in this case, the flow will not continue until someone on the channel has responded to any inputs required within the card. The flow will continue once the anyone in the Teams channel responds but will only return dynamic content for one (1) response per responder and per card.

Image_03.jpg

Let’s see the Flow steps,

Step #1:

Whenever I’m not feeling well and require a few days of leave to take rest, I will manually trigger the flow to submit a leave request to my manager. So, I’m going to use a manual trigger template as a first step.

Image_04.jpg

Step #2:

In the second stage, we are going to create approval content like title, assigned to, details, and attachment (link to the item to approve). So, I have chosen the Create an Approval template and configured the required information.

Before continuing to configure essential information. Let’s know about the Create an approval template.

Create an approval card is a template for the approval request that’s sent to approvers. Configure it in a way that’s useful for your approver.

Moreover, create an approval action provides several tokens, including Responses and Outcome. Use these tokens to run an approval request flow.

Image_05.jpg

 

Approval type: When a flow with Create an Approval action is configured with Approve/ Reject – First to respond, it waits until assigned to approve or assigned to rejects the approval request.

Title: Request for sick leave.

Assigned To:  My manager's email address.

Details: Addition information that you want to be sent to the approver.

Item link: If you have any document in SharePoint then share URL for the approval.

Item link description: Addition information about the shared document. 

Requestor:  I have added dynamic content like User email which gives the email address of the person who is manually triggered the flow.

Most importantly Create an approval action, create an adaptive card based on configuration information.

In the next step, we are going to select the Microsoft Teams Connector!

Step #3:

I have chosen Microsoft Teams connector “Post your own adaptive card as the Flow bot to a user”. As per our scenario, we are going to post sick requests to my manager.  So, Post your own adaptive card as the Flow bot to a user connector director our adaptive card to Team members. We need to choose a connector. 

As per our scenario, a sick leave approval request is posted to my manager. So, I have chosen “Post your own adaptive card as the Flow bot to a user” Microsoft Teams connector. This connector directs the adaptive card to concerned members.

Image_06.jpg

Recipient: my manager's email address is configured.

Message: we have passed the adaptive card which is created in the previous step.

Step #4:

Approver receives adaptive card approval request in Microsoft Teams. Meanwhile, the flow needs to wait until approver responds to our request. The Response can be either approved or rejected. So, I have used Wait for an Approval template which halts the flow until approver responds to our request.

Image_07.jpg

Approval ID: I have added dynamic content like Approval ID which gives the ID of the approval.

Step #5:

To evaluate the approver response then we need to add a condition to a flow. Chose a condition action

Image_08.jpg

On the condition card, select an empty area in the box on the left. The dynamic content list opens. Select the Outcome parameter to add it to the box.  

In the box in the middle of the condition card, select is equal to

In the box on the right, enter the Approve text.

Step #6:

Based on the approval response, we need to send an email to the requestor.

image_09.jpg

If the response to the request is Approve, you might want to send an email to the requestor. With email contain:

Subject: Sick leave is Approve

Body: Approved

If the response to the request is Reject, we might want to send an email to the requestor. With email contain:

Subject: Sick leave is Reject

Body: Rejected

Well, that’s it, we’re done Save the Flow.

 

Let’s test the flow

Our flow will trigger manually. So, I have triggered the flow by clicking the Run flow button.

Image_10.jpg

 

Immediately Sick leave adaptive card request is posted to my manager in Microsoft Teams and waiting for a response:

Image_11.jpg

 

Based on my manager approval, our flow will immediately capture the response and send the email to the requestor.

Image_12.jpg

 

If my leave request is approved by my manager, then an approved email is sent to me

Image_13.jpg

 

Similarly, if my leave request is rejected by my manager

Image_14.jpg

 

Then, the flow will immediately send a reject email to me.Image_15.jpg

 

Perhaps, this article will also give you some inspiration on other ways to make use of Power Automate. 

Thanks for reading!

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/