User Review( votes)
Most of you might already be aware of the fact that we can use Power Automate to automatically push/send the notification to the Microsoft Teams channel. In this blog, let’s step it up and understand how we can create our own adaptive cards and use Power Automate to post the card to the Microsoft Teams channel. All of these are going to be triggered on the events in Dataverse. So, the scenario is that this power automated flow will run when the opportunity is “Won” and this will send the notification to the owner of the opportunity in Microsoft Teams. In other words, we are going to grab the required data from opportunity and put that into adaptive cards further to be sent to MS Teams. Let’s see the step-by-step process of the same.
First, we will start designing the adaptive cards, for this go to: https://adaptivecards.io/designer
Click on “Samples”
Now, have a look at all of the available sample cards and pick one that you can start with.
Here we will choose the below one and click on “Try it Yourself”.
You will see the preview of the adaptive card and next to that are the card structure and element properties along with the payload editor just at the bottom. This is nothing but JSON that we will use later in our power automated flow.
Now let’s first get rid of the fields that we do not require from the selected sample adaptive card.
Next, we will edit the below details, but before that, we need to make sure to select the host application that we are going to show this adaptive card in.
Select the host application from the list – since we are using Microsoft Teams with a light background, to show this card we’ll select the below option from the list.
Now let’s edit the field as shown below –
We also want to tag the owner of an opportunity in the adaptive card notification being sent to Microsoft Teams, so we will put it as shown below:
Topic of an opportunity to be displayed in the teams, so below is how it can be mentioned:
Let’s show the total revenue of the opportunity that is won.
Note: We are going to set the dynamic values for the owner, topic, and annual revenue of the opportunity soon in the Power Automate flow, that’s the reason we have placed them into “<..>” for now so that we can recognize them easily for the dynamic selection later on in the automated flow.
To make the adaptive card more interactive and we can add the image/gif as shown below:
From the card elements on the left-hand side, simply drag the “Image” element and drop it on the adaptive card, and set the URL of an image to show the image of your choice.
Once you set the Url, it will look like below:
Next, we have to enable the provision allowing users to open the opportunity record (won) directly from the Microsoft Teams, so we will add a link option to this adaptive card. Click on the edge of the card and further click “Add an action”.
Select the below option:
And give a relevant names to the action.
Set the URL of the opportunity record that is going to be won, so when the user clicks on “Open Opportunity” on adaptive cards in teams, it will open the actual opportunity record that is won.
For this, we are going to get the partial Url of the opportunity record. This is how it should be set –
We are copying only till “id” in the Url of an opportunity and not over the last part of the Url–
Again, we are going to dynamically select the opportunity at the place highlighted above, so let’s copy the URL to the Url field as shown in the below image.
We have successfully designed our adaptive cards so far to use in our power automated flow, now let’s design our Power Automate flow.
Choose to create a new automated cloud flow.
Skip this over. We can now name the flow and configure the steps going forward.
Select the below trigger.
Since we want to trigger the flow on status update of an opportunity to “Won”, we are putting the value as shown below:
Now, add a new step.
Next, we have to get the information from the owner of an opportunity, so we will select the below operation and set the appropriate values to the fields.
As we want to also tag the owner of the opportunity in the adaptive card that will be posted to Microsoft Teams, we will perform the below step to get the mentioned token which will tag the owner user in the message in adaptive cards.
Here, it is going to be the user name from the previous step.
Let’s proceed to the last step now, as we want to post the adaptive card to the Microsoft Teams channel, we will design the step as shown below:
We are choosing to post the adaptive card to the Microsoft Teams channel with a flow bot. Along with this, we will also have to put the JSON of the adaptive card into the step. So, configure the step as shown below, but before this, let’s go back to adaptive card designer and copy the card payload (JSON) as seen below:
Come back to flow, and set the fields as shown below:
Now in the “Adaptive Card” field, paste the JSON (Card payload) that we copied earlier.
We will have to do some dynamic selection over here in this JSON.
At the place of “<Owner>”
Do the dynamic selection for the topic of the opportunity.
Select the dynamic value.
Lastly, since we want to be able to open the actual won opportunity record from the adaptive card in teams, we will dynamically select the opportunity.
We have completed designing the flow, now let’s save it and test it.
After clicking on “Test”, go back to CRM and win an opportunity having some value in actual revenue.
You will see the channel showing one notification in teams.
If you further open it, it will show you the adaptive cards with all the details that we have dynamically set in our flow and configured for our adaptive card.
If you want to see the Opportunity record, simply click on “Open Opportunity”, it will navigate the user to the opportunity record that is won earlier.
As illustrated, we have been able to successfully design the adaptive cards and post it onto the Microsoft Teams with the help of MS Teams integration using Power Automate.