So when delivered to teams the json will transform into the native ui automatically adapting itself to microsoft teams the easiest way to get started with adaptive cards is to check out the samples that have been provided for us we have been provided with a wide variety of samples to choose from to try out any specific sample we can click on try it yourself so this will take us to the adaptive cards designer web page which allows us.
To design our adaptive card right here on the top we have been provided with selecting the host so that we can see how this adaptive card would render for example microsoft teams this is how the adaptive card would render inside of microsoft teams if i was to change this to the dark theme experience for microsoft teams the card will automatically adapt and render the.
Ui json schema that gets generated for this specific adaptive card is provided for us right here at the bottom and the easiest way for us to copy the json is by clicking on copy card payload to render these cards to microsoft teams we have power automate actions readily available in power automate i will head over to create and create a simple instant cloud.
Flow a flow that will trigger manually on click of a button i'll click create i've given my flow a name i'll add a new step and search for post adaptive card one of the native actions for the microsoft teams connector is post adaptive card in a chat or a channel i'll go ahead and select this now you can post these cards either as the flow bot or.
As the user the user's context under which the flow is running in this case i'll select the flow bot and i would like to post this adaptive card in either a channel or a chat with the flow bot or as a group chat in this case i'll pick chat with the flow bot since i want to send this out to a specific recipient and the recipient in this case will be the user who is triggering this flow so i'll pick the user email from dynamic content.
And adaptive card is where we need to post the adaptive card that i copied from copy card payload so i'll paste that json code in here save my flow and for testing purposes i will click on test manual and i will run this flow now once this flow triggers it will go ahead and post an adaptive card as the flowbot to reza who is the.
Recipient that's the user who's running the flow now inside microsoft teams the flowbot has sent me a message and that message is this rich adaptive card experience now the data that's being showcased here is hard coded that's because the adaptive card information that has been provided here is hard coded so let's transform this and make this dynamic in power automate i need the weather information for my current location so right before posting.
This adaptive card i will insert a new step there is an action called get current weather information from the msn weather connector i will select this it's asking me for my location when i manually run this flow flow can track my location so from dynamic content i will pick the full address in the adaptive card json the location was redmond so i'm going to.
Change this to my location i'll just plug in state as the dynamic property here is the date and time for this i will select the timestamp at which this flow got triggered the current temperature which was hardcoded now i will get the current temperature from the dynamic content property temperature and then i have other details here for temperature high temperature low i'm.
Going to keep this simple i will remove the specific object of type column you can always validate your results you can copy this json go back to adaptive cards and paste it right here on the payload so you can see that the card is being rendered in some form or the other now that i have the adaptive card built out dynamic based on my location i will test this flow again the flow has triggered picked up my current weather information and posted.
Posts Related:
The adaptive card and the flow bot sends me that adaptive card message
I am based out of texas that's the current date and time and that's the current weather at my location now in the adaptive cards designer experience when i go to new card i can pick from a wide variety of templates that have been provided for us and when i pick a specific template i have the ability to update the template i can select controls either remove them.I can drag and drop elements on the card experience and the json code is automatically being generated for me another option we have is to start from a blank card experience one thing i highly recommend when you're working with microsoft teams power automate when it posts the adaptive cards it respects a specific targeted version so ensure that you select the host app as teams so that that specific target version is put in play.
Now let's take a use case wherein i have a microsoft team called my hr team and i would like to post an adaptive card which gives a happy birthday message to any member of the team who have their birthday today first i would like to showcase text happy birthday so from the left hand side under elements i'll pick the text block drag it and place it on the card the moment i do that the card payload editor adds that json on the body of the card.
Now for every control that we add to the card we have relevant properties associated with it for example for my text block i have the text property so here i will say happy birthday there are various other properties to choose from the size i would like to increase the font size to large we'd like to make this bold and the color for this i will go ahead and pick an accent color.
My horizontal alignment i'll put it right on the center next i would like to display the picture of the user whose birthday it is today and the name of that user and i would like to place them horizontally next to each other to do that i can add a column set container and in this container right here we have the option to add columns so if i select this it has now created a couple of columns for me in the first column i would like to place the image of the user so i'll pick the image control drag it and place it.
Right in this column image control has specific properties associated with it one of them is the url for now i'm just going to enter some text i'm just mentioning user image url image has a style property so i'm going to style it in the form of a person i can even make it actionable so when the user clicks on that image then something should happen for example.
Open a url next i want to show the display name of the user so i'll pick a text block and drop it in the column next to it the text i will call it user display name all of these we will make dynamic inside of power automate now for my first column the width i will change it to automatic so it automatically sets the width i will add another text block for this i will give a message have a nice day.
And then finally i would like to place another image the url is a url of a gif on the web so i'm just going to select that so it displays that specific image inside my adaptive card experience i'll go ahead and copy the card payload i'll pick the scheduled cloudflow and i will run this flow every day let's say at 8am i'll click create.
Next i will add a step to get the group members from my microsoft team there is a connector called office 365 groups as part of this connector we have an action called list group members so i'll select this action and here i need to pick the id of my group if i open this drop down it will list out all my microsoft teams i'll go and pick my hr team.
My next step would be to loop through all the items i will pick the apply to
Each loop and i will loop through the value property dynamic content coming from the list group members action now for each of these users that i'm retrieving i need to check whether today is their birthday or not and to do that i have to get their profile information and there is an action called get user.Profile from the office 365 users connector i will select this here i need to provide the user principle name that is provided as a dynamic content property so i'll select this and as part of the profile action we will get the birth date information for the specific user now we need to check if today is the user's birthday so for that i will add a condition.
Here i will write a simple expression to format the user's retrieved birth date into purely month and day since that's the only information that i require to check if that matches with today's month and date so i'll head over to expression and use the format date time expression the first parameter i'll head over to dynamic content and from the get user profile action i will pick the birthdate this will plug in the formula for that.
Specific property i will format this as month and date i will click ok now i need to check if this is equal to once again i'll use an expression format date time we have a function called utc now which gives me the current date and time i will format this as month and date if this matches that means today is the user's birthday.
My next step is to go and post that adaptive card so i'll add an action post an adaptive card in a chat or a channel this one i will post in a channel in microsoft teams it opens up additional options one for selecting my team my team is my hr team and then as part of this team it will load up all the channels so i'll pick the general channel and right here is where i can paste my adaptive card payload.
The user display name i will delete this text from dynamic content i will pick the display name of the user from the user's profile and for the user's image i need to get the user's photo to do that right after get user profile i'll add an action called get user photo this requires the user principle name.
So i'll select that now you only want to fetch the photo if today is the user's birthday so i'll select this and drag it in the yes branch i would like to perform this action before posting the adaptive card so i'll select the adaptive card and move it down in the post adaptive card action the property where i need to enter the url of the image which is the user's photo i will replace this with you need to provide the base64 encoded information.
So it directly plugs in that image i'll paste my text and right after this i will head over to expression and use the base64 function and the parameter for this will come from dynamic content image file content from the get user photo action i'll click on ok this completes my flow i'll click on save as per my user profile information my birth date is set as march 18th that's.
The date i'm recording this video and i am a part of the hr microsoft team this flow is scheduled to run every day at 8 00 am for testing purposes i will manually run this the flow has triggered it will go and fetch all the members of this microsoft team check if it has anyone's birthday today if yes it will go and post the adaptive card let's head over to microsoft teams here is the general channel for my hr.
Team as per the profile information today is reza's birthday so it goes ahead and sends a happy birthday adaptive card now you can expand this in various other scenarios for example if a new user is added as a member to a microsoft team there is a trigger in power automate for that so i can pick that information about that new user who's joined the team and an adaptive card can be sent out to the team.
We can welcome that user an actionable button if i click this it will open that user's profile information another scenario where we can leverage adaptive cards is teams messaging extensions when we receive messages and this could be 1s21 chat messages group chat messages or messages and channels in our teams for each of these messages if i go to the three ellipses here we have something called as actions.
Wherein we can take specific actions we can create flows that allow us to create our custom actions that we can call based on this messaging experience so let's take a use case whenever i receive these chat messages if they are task related maybe i put them in microsoft to do so i can track them and close them out to create this experience i will create an instant cloud flow and here i will pick the trigger for a.
Selected message in microsoft teams and click create i will give my flow a name the selected message action gives us the ability to create an adaptive card and the beauty of this is when i select that it brings the entire adaptive cards designer experience directly inside of power automate and the card that's created here is based on a basic template let's try and modify this.
For the first control if i head over to element properties i'll change the text to create a microsoft to do task the next section i will remove this the first thing i need from the user is the title of the task for the input text element i'll change the placeholder to task title for the next element i will ask for the due date of the task i don't want text boxes here remember these are templates so you're free to.
Make changes i want the date input so i'm going to select this and place it right here and the user can go ahead and submit it now whenever you have these input controls you need to ensure that they have a specific id property associated with it so for this one i will name this as i like to follow this naming convention which is ac meaning adaptive card and then my control which is task title.
For my due date column i'll do the same ac due date this completes my adaptive card i'll click on save so that's the adaptive card that will launch when the user will trigger this flow for a selected message in microsoft teams i would like to add a microsoft to do i'll add a new action add a to-do so i'll select this which list in to-do do i want to add it.
To i'll add it to my task list the title of my task if you look at dynamic content i have my input controls the ids that i plugged in are available right here so i can directly read their values so i need the title of the task so i'll pick it from the ac task title property the due date i will pick it from my due date property the status of the task i'll set it to not started content section of this task.
I'll plug in message subject the trigger action has all that information for us if i search for subject we have a dynamic property called message subject if you want the body of the message we can even get that in its true form it's html form or in its plain text form i'll pick plain text i would like to also give a link in microsoft to do to the teams message for which i created this to do for.
I will swap over to the code view here and write simple html i'll create an anchor tag the href for which will be the link to the message i have that in dynamic content i complete my html and once my to do task is created i would like to notify myself that this task has been created with a link to the task in teams and to do that once again we can use an.
Adaptive card so post an adaptive card in a chat or a channel as the flowbot post in chat with flobot the recipient i can pick from the dynamic content property called originating user id the user who triggers the flow now for the adaptive card in the adaptive cards designer i'll start with a blank card add a text block and with the card selected i will add an.
Action and this action would be to open a specific url the url property would be a url to my to-do task the title would be open to do i'll copy the payload go to my flow paste it in here my text i will plug in the title of the task and the url would be the url to my to do task now to do tasks have a very specific url.
And that url looks like this todo.office.com tasks slash id slash the id of the task slash details if i search for id under dynamic content the adder to do action gives me that information so i'll just plug that right here and i will go ahead and save my flow the flow is saved now in microsoft teams for any message if i go to the three ellipses.
Go to more actions here is my flow that i created create a to-do task let's see like this this will now launch the adaptive card for us directly inside of microsoft teams i can provide the title of my task and i can define a due date for my task and click submit and the moment i do this flow will create a microsoft to-do and once it does that it will send me.
An adaptive card that has the name of my task and an actionable button to open that specific to do if i select this it will directly take me to microsoft to do and show me my new task that has been created and here are the details the title of the task the due date and if you look at message body this information is coming from my microsoft team's message here is that original message and i even have a link to the message.
If i select it it will directly take me to microsoft teams directly to that specific message and here's that message for which i created the to do and to do once i complete my task i can click completed now there are many times when you want to send an adaptive card from floor to teams and we need the flow to wait for the user to respond to that adaptive card.
Let's take travel request as an example my users record travel requests in a system of record in my scenario here it is sharepoint so whenever a travel request comes in i want an adaptive card created inside of my hr microsoft team so my team is notified about it and at the same time i want the hr team to take a decision basically an approval process around whether the request that has come in they accept it or not and they can.
Also plug in their commands if required in power automate since i want the flow to trigger whenever a new item is created in my sharepoint list i will select the automated cloudflow and my trigger is when an item is created i'll give my flow a name and click create i'll pick my site address i'll pick the sharepoint list next i will add a step post an adaptive card.
And wait for a response since i want to wait for the user to give me that response in microsoft teams so i'll pick this action once again posted as the flowbot and posted in a channel in microsoft teams i will select my hr team and the channel will be the general channel update message is when a response is given what's the message you would like to give at that instant i'll say thanks for the response and the message is where we need to plug.
In the adaptive card let's get that json from adaptive cards designer i'll first enter a text block here i'll display the title of the travel request that has come in next i'll give the name of the user who has made that request then i want to provide a link directly to that item in sharepoint so i'll add an action set and in this action set i'll add an action open url the url will be linked to item.