Wednesday, 16 October 2024

Adaptive Card: Send Form using Adaptive card in MS Teams to group members

In this blog, we will be learning about Adaptive Cards and how to send an adaptive card Form in MS Team's chat and get response details.

Our business scenario involves obtaining project status details from project leads on a monthly basis. Previously, these updates were collected via email and manually recorded in an Excel file. Now, we have implemented a more efficient solution: project status updates can be submitted directly within MS Teams using- an Adaptive Card, and the information is automatically saved into a SharePoint list.

Here, we will be creating two Power Automate flows:

  • To send Adaptive card in MS Teams to group members
  • To get project status using Adaptive card

Create Flow

1). Sign in to Power Automate

2). Open the flow, click on the Create option, and select "Scheduled Cloud Flow".

Enter Flow name.
Set the flow recurrence interval as monthly.
Click on the Create button.


3). Add an action "List group members" and enter team name from the dropdown in Group Id parameter. Its used to get all the members details present in the teams in an array.


4). Add "Apply to each" loop and enter previous step output value as input value.

5). Add an action "HTTP" and enter the parameter values as per table. The URI value will be generated automatically in the second flow in step 8.


Method POST
URI https://prod-99.india.logic.azure.com:443/workflows ...
Headers
{
  "Content-Type": "application/json"
}
Body
{
  "email": mail_value_from_ListGroupMembers
}
Authentication None

6). The first complete flow with all the actions will look like below.



7). Create another flow, click on the Create option, and select "Automated Cloud Flow".

Enter Flow name.
Choose the flow trigger as "When a HTTP request is received". The trigger is not directly available.
So, click on the Skip button.


Now in the Power Automate flow designer search for the flow trigger again. Here, you will find it.


8). In the trigger set the parameter values as shown below.

HTTP POST URL will be generated automatically and will be used in step 5

{
    "type""object",
    "properties": {
        "email": {
            "type""string"
        }
    }
}



9). Now, add an action "Post adaptive card and wait for a response".

Add mandatory parameter values as shown in below image. Refer step 11 for details.


10). Add an action "Get user profile (V2)" and enter User (UPN) value as project manager dynamic value from above step.

Then, add "Create item" action to save the record in the SharePoint list.





Now we will discuss how to create Adaptive Card parameter value.

11). Open Adaptive Cards Designer portal.

Select host app as "Microsoft Teams" and Target version as 1.4
Then, create the Adaptive card design according to your requirements.

Once Adaptive Card design is complete. Click on "Copy card payload" and paste it into the Adaptive Card parameter value (Step 9).

The Id property of an element or control is crucial, as its utilized when accessing control values within a flow.

Get project status using Adaptive card - CARD PAYLOAD
{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.4",
  "id": "myProjectACE",
  "body": [
    {
      "type": "TextBlock",
      "text": "Project Status Details",
      "wrap": true,
      "id": "applicationHeader",
      "size": "ExtraLarge",
      "weight": "Bolder",
      "color": "Default",
      "horizontalAlignment": "Center",
      "separator": true
    },
    {
      "type": "Image",
      "url": "https://cdn4.iconfinder.com/data/icons/alter-3d-scenes/256/business___
	  graph_chart_analytics_statistics_presentation_project_3d_people2x.png",
      "id": "projectImage",
      "separator": true,
      "horizontalAlignment": "Center"
    },
    {
      "type": "TextBlock",
      "text": "Kindly complete this form",
      "wrap": true,
      "separator": true,
      "size": "Large",
      "color": "Dark",
      "horizontalAlignment": "Left",
      "fontType": "Default",
      "weight": "Default",
      "id": "formHeader"
    },
    {
      "type": "Input.Text",
      "id": "projectName",
      "label": "Project Name",
      "isRequired": true,
      "errorMessage": "This is required"
    },
    {
      "type": "ColumnSet",
      "columns": [
        {
          "type": "Column",
          "width": "stretch",
          "items": [
            {
              "type": "Input.Text",
              "id": "projectCode",
              "isRequired": true,
              "label": "Project Code",
              "errorMessage": "This is required"
            },
            {
              "type": "Input.Date",
              "id": "startDate",
              "label": "Start Date"
            }
          ]
        },
        {
          "type": "Column",
          "width": "stretch",
          "items": [
            {
              "type": "Input.Text",
              "id": "teamSize",
              "label": "Team Size"
            },
            {
              "type": "Input.Date",
              "id": "endDate",
              "label": "End Date"
            }
          ]
        }
      ],
      "id": "projectColumnSet"
    },
    {
      "type": "Input.ChoiceSet",
      "choices": [
        {
          "title": "Active: The project is currently being worked on by the project team",
          "value": "Active: The project is currently being worked on by the project team"
        },
        {
          "title": "Completed: Work on the project has finished, and all deliverables/tasks
                    have been completed",
          "value": "Completed: Work on the project has finished, and all deliverables/tasks
                    have been completed"
        },
        {
          "title": "Cancelled: The project has not finished, and work on the project will
                    not continue",
          "value": "Cancelled: The project has not finished, and work on the project will
                    not continue"
        },
        {
          "title": "On Hold: The project has not finished, and work on the project has
                    been temporarily suspended",
          "value": "On Hold: The project has not finished, and work on the project has
                    been temporarily suspended"
        }
      ],
      "id": "projectStatus",
      "label": "Project Status",
      "isRequired": true,
      "errorMessage": "This is required"
    },
    {
      "type": "Input.ChoiceSet",
      "choices.data": {
        "type": "Data.Query",
        "dataset": "graph.microsoft.com/users"
      },
      "id": "projectManager",
      "label": "Project Manager / Account Manager",
      "isRequired": true,
      "errorMessage": "This is required",
      "isMultiSelect": false
    },
    {
      "type": "Input.Text",
      "isMultiline": true,
      "id": "comments",
      "label": "Comments(if any)"
    },
    {
      "type": "Input.Toggle",
      "title": "I accept the terms and agreements",
      "id": "acceptTerms",
      "isRequired": true,
      "errorMessage": "You must accept the terms to continue.",
      "label": "Please check the box below to accept the terms and agreements:"
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Save",
      "id": "save",
      "iconUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXN
	  SR0IArs4c6QAAAhhJREFUOE9jZKAyYKSyeQwoBprMuO3/n4FBg+/XG9cYAyElXoYffDALX//jfoNs+ZpLr59
	  8ZxVIOZGp+QBZHG6gybTbfgxMDBtBkmK/XjD0eEkxPHjyBK7WzMAAxTNxiy4xvGSTfMD6/7cjsqEIA2fermf
	  4z9AAM7DVVZTh2LlzcEPCvb0xDHzFJsHwn4ERxVCEgdNvNzAwMtSDdDF/eMSwLEaT4eylSwx//v1lEODlYzD
	  T14Mb+OvPP4aA2ecY/gnKQcT+MzSeyVQFOwargd/fPmUwleZkcNcQYWBhZkJx2Z+//xh2Xn/NcObZDwYOYWn,
	  cBhpNvDqPiZ0tEWzhvz8Mf75/Yfj/7x/WRMDIxMzAwsnDAKJB4N/PX/PP5WsnobhQr//8ATZOHntyktGv718
	  OXio0dKCvgRI8zAy8bNjT/edf/xlefPmLiCRCLsw14WXwVuHE6/stt78zTDn7GayGoJc3h4ky/P31i+Hjp09
	  YDeXn42NgZmNj8F31mjgDd0SIMfz+/Yfh67dvWA3k5uJiYGVlYfBY8Yp4Az9/+crw7PkLrAZKSUow8PJw4zd
	  Qv/fMelZu/gCQCSAXEgNgLvz59eP6y8UmQSjJRrd5TwAjB+96ZlZ2hkYbbmLMY6g/8pXh7+8fDH9/fPK/Wuu
	  2CcVAEEejcacvw///FolanEQl8PnXvh9kYGA8fqPBfQvMBbQtYInyJwFFAGUS8BXW+cfxAAAAAElFTkSuQmCC"
    }
  ]
}



12). The second complete flow with all the actions will look like below.



Now it's time to test the flow. Manually run the flow and wait for sometime.

Project Status form in Adaptive Card output for Teams web application.






Fill out the form and click Save button. Error message will be shown if mandatory fields are not filled.


Check the second flow history and move to action "Post adaptive card and wait for a response".

Open "Show raw outputs" and you can see that the saved form response is in the data node.

People Picker in Adaptive card returns the Microsoft Entra ID (Azure Active Directory) of the user selected. Due to that the user details are fetched using "Get user profile (V2)" action and its output is used.




Refer Adaptive Card blog series:
Adaptive Card: Power Automate send welcome message when new team member added
Adaptive Card: Power Automate send birthday greetings to team members
People Picker in Adaptive Cards
Adaptive Card: Send Form using Adaptive card in MS Teams to group members


I hope this will help all of you! 🧲
Feel free to provide feedback.


🚀 "Happy Coding" 🚀

Sunday, 15 September 2024

People Picker in Adaptive Cards

In this blog, we will be learning about People Picker in Adaptive Cards.

People Picker is an input control in Adaptive Card. It allows users to quickly search and select valid user accounts for peoples within the organization.

People Picker supports the following features:

  • Searches single or multiple users.
  • Selects single or multiple users.
  • Reassigns to single or multiple users.
  • Prepopulates the name of selected users.


Implementation of People Picker

People Picker in Adaptive Cards is implemented as an extension of the Input.ChoiceSet control.

Schema

The following properties are additions to the Input.ChoiceSet schema to enable People Picker experience on the Adaptive Card.

Input.ChoiceSet control

The choices.data property is supported in version 1.6; however, in my testing, it also worked for version 1.4. The JSON format data is passed into the property.

Property Type Required Description
choices.data Data.Query No Enables dynamic auto complete for different user types, by fetching results from the dataset specified.

Data.Query

Property Type Required Description
dataset String Yes The type of data that must be fetched dynamically.

dataset

The following table provides predefined values as dataset for people picker:

dataset Search Scope
graph.microsoft.com/users Search all members across the organization.
graph.microsoft.com/users?scope=currentContext Search within the members of the current conversation, such as chat or channel in which the particular card is sent.

Data Submission

We can use Action.Submit or Action.Execute to submit selected user data. The payload received is a list of Microsoft Entra IDs or the IDs provided in the static list. In People Picker, when a user is selected in the control, the Microsoft Entra ID of the user is the value sent back. The Microsoft Entra ID is a string and uniquely identifies a user in the directory.


Create Flow

1). Sign in to Power Automate

2). Open the flow, click on the Create option, and select "Instant Cloud Flow".

Enter Flow name.
Choose the flow trigger as "Manually trigger a flow".
Click on the Create button.




3). Add an action "Post adaptive card and wait for a response".
Add mandatory parameter values as shown in below image.


In this step an Adaptive Card with People Picker control will be sent to user in MS Teams chat. It will wait till the user has search & selected the user(s) and clicked on 'Save' button.

4). Add a loop "Apply to each" and set input value "Select an output from previous steps" as below

split(body('Post_adaptive_card_and_wait_for_a_response')?['data']?['peoplePickerChoiceSetControlID'],',')

Then add an action "Get user profile (V2)" and enter User (UPN) value as current item.

Here, we are retrieving the user(s) that has been selected and submitted from above step. When a user is selected in the control, the Microsoft Entra ID (Azure Active Directory) of the user is the value sent back. The value will be comma separated user ID's if multi select is enabled.
To compare, we will iterate over the values and verify if the chosen user matches the one we have received.


Repeat above step for all the four People Picker controls added in Adaptive card.

Now we will discuss how to create Adaptive Card parameter value.

5). Open Adaptive Cards Designer portal.

Select host app as "Microsoft Teams" and Target version as 1.4
Then, create the Adaptive card design according to your requirements.

Once Adaptive Card design is complete. Click on "Copy card payload" and paste it into the  Adaptive Card parameter value (Step 3)



People Picker - CARD PAYLOAD
{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "id": "peoplePickerCard",
    "msteams": {
        "width": "Full"
    },
    "body": [
        {
            "type": "TextBlock",
            "size": "ExtraLarge",
            "weight": "Bolder",
            "text": "People Picker in Adaptive Cards",
            "id": "peoplePickerTitle",
            "horizontalAlignment": "Center",
            "fontType": "Default"
        },
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "People Picker with organization search - 
                             Default",
                    "wrap": true,
                    "id": "peoplePickerDefault",
                    "weight": "Bolder",
                    "spacing": "None"
                },
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "width": "stretch",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Single select",
                                    "wrap": true,
                                    "id": "textBlockSingleSelectDefault",
                                    "fontType": "Monospace"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "choices.data": {
                                        "type": "Data.Query",
                                        "dataset": "graph.microsoft.com/users"
                                    },
                                    "id": "peoplePickerControlSingleSelectDefault",
                                    "placeholder": "Search user"
                                }
                            ]
                        },
                        {
                            "type": "Column",
                            "width": "stretch",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Multi select",
                                    "wrap": true,
                                    "id": "textBlockMultiSelectDefault",
                                    "fontType": "Monospace"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "choices.data": {
                                        "type": "Data.Query",
                                        "dataset": "graph.microsoft.com/users"
                                    },
                                    "id": "peoplePickerControlMultiSelectDefault",
                                    "isMultiSelect": true,
                                    "placeholder": "Search users"
                                }
                            ]
                        }
                    ]
                }
            ],
            "backgroundImage": {
                "url": "data:image/gif;base64,
                R0lGODlhCAABAIABAOrbyAacDywAAAAACAABAAACA4RvBQA7",
                "fillMode": "Repeat"
            },
            "spacing": "ExtraLarge",
            "separator": true
        },
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "People Picker with organization search - 
                             User Preselection",
                    "wrap": true,
                    "id": "peoplePickerPreselection",
                    "spacing": "ExtraLarge",
                    "weight": "Bolder"
                },
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "width": "stretch",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Single select",
                                    "wrap": true,
                                    "id": "textBlockSingleSelectPreselection",
                                    "fontType": "Monospace"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "choices.data": {
                                        "type": "Data.Query",
                                        "dataset": "graph.microsoft.com/users"
                                    },
                                    "id": "peoplePickerControlSingleSelectPreselection",
                                    "placeholder": "Search user",
                                    "value": "b8e32ece-6d19-488e-96cf-7703c5xxxxxx"
                                }
                            ]
                        },
                        {
                            "type": "Column",
                            "width": "stretch",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Multi select",
                                    "wrap": true,
                                    "id": "textBlockMultiSelectPreselection",
                                    "fontType": "Monospace"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "choices.data": {
                                        "type": "Data.Query",
                                        "dataset": "graph.microsoft.com/users"
                                    },
                                    "id": "peoplePickerControlMultiSelectPreselection",
                                    "isMultiSelect": true,
                                    "placeholder": "Search users",
                                    "value": "b8e32ece-6d19-488e-96cf-7703c5xxxxxx,
                                              e59ec47a-1e87-4ecf-983c-6b7efdxxxxxx"
                                }
                            ]
                        }
                    ]
                }
            ],
            "spacing": "Padding",
            "backgroundImage": {
                "url": "data:image/gif;base64,
                R0lGODlhCAABAIABAOrbyAacDywAAAAACAABAAACA4RvBQA7"
            }
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Save",
            "iconUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg
            AAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAhhJREFUOE9jZK
            AyYKSyeQwoBprMuO3/n4FBg+/XG9cYAyElXoYffDALX//jfoNs+ZpLr5
            98ZxVIOZGp+QBZHG6gybTbfgxMDBtBkmK/XjD0eEkxPHjyBK7WzMAAxT
            Nxiy4xvGSTfMD6/7cjsqEIA2fermf4z9AAM7DVVZTh2LlzcEPCvb0xDH
            zFJsHwn4ERxVCEgdNvNzAwMtSDdDF/eMSwLEaT4eylSwx//v1lEODlYz
            DT14Mb+OvPP4aA2ecY/gnKQcT+MzSeyVQFOwargd/fPmUwleZkcNcQYW
            BhZkJx2Z+//xh2Xn/NcObZDwYOYWncBhpNvDqPiZ0tEWzhvz8Mf75/Yf
            j/7x/WRMDIxMzAwsnDAKJB4N/PX/PP5WsnobhQr//8ATZOHntyktGv71
            8OXio0dKCvgRI8zAy8bNjT/edf/xlefPmLiCRCLsw14WXwVuHE6/stt7
            8zTDn7GayGoJc3h4ky/P31i+Hjp09YDeXn42NgZmNj8F31mjgDd0SIMf
            z+/Yfh67dvWA3k5uJiYGVlYfBY8Yp4Az9/+crw7PkLrAZKSUow8PJw4z
            dQv/fMelZu/gCQCSAXEgNgLvz59eP6y8UmQSjJRrd5TwAjB+96ZlZ2hk
            YbbmLMY6g/8pXh7+8fDH9/fPK/Wuu2CcVAEEejcacvw///FolanEQl8P
            nXvh9kYGA8fqPBfQvMBbQtYInyJwFFAGUS8BXW+cfxAAAAAElFTkSuQmCC",
            "id": "peoplePickerSubmit"
        }
    ],
    "backgroundImage": {
        "url": "data:image/gif;base64,
        R0lGODlhCAABAIABAPjw5QacDywAAAAACAABAAACA4RvBQA7",
        "fillMode": "Repeat"
    }
}


6). Complete flow with all the actions will look like below.



Now it's time to test the flow. Manually run the flow and wait for sometime.

People Picker in Adaptive Card output for Teams desktop application.


People Picker in Adaptive Card output for Teams web application.


Select the user(s) and click Save button.



Refer Adaptive Card blog series:
Adaptive Card: Power Automate send welcome message when new team member added
Adaptive Card: Power Automate send birthday greetings to team members
People Picker in Adaptive Cards
Adaptive Card: Send Form using Adaptive card in MS Teams to group members


I hope this will help all of you! 🧲
Feel free to provide feedback.


🚀 "Happy Coding" 🚀

Wednesday, 28 August 2024

Adaptive Card: Power Automate send birthday greetings to team members

In this blog, we will be learning about Adaptive Cards and how to send a birthday greetings automatically to Team's channel to team members.

Create Flow

1). Sign in to Power Automate

2). Open the flow, click on the Create option, and select "Scheduled Cloud Flow".

Enter Flow name.
Set the flow recurrence interval as daily.
Click on the Create button.


3). Initialize variable of Array type.

4). Add an action "List group members" and enter team name from the dropdown in Group Id parameter. Its used to get all the members details present in the teams in an array.


5). Add "Apply to each" loop and enter previous step output as input value.

6). Add an action "Get user profile (V2)" and enter User (UPN) value as "User Principal Name" dynamic content from step 4.

7). Append the array variable (defined in step 3) value in JSON format for "Display Name", "User Principal Name", "Birthday".

{
  "name": "@{outputs('Get_user_profile_(V2)')?['body/displayName']}",
  "email": "@{outputs('Get_user_profile_(V2)')?['body/userPrincipalName']}",
  "birthday": "@{outputs('Get_user_profile_(V2)')?['body/birthday']}"
}


8). Add an action "Filter Array" and enter array variable in From parameter value.

@equals(formatDateTime(convertFromUtc(item()['birthday'], 'India Standard Time'), 'MM-dd'), formatDateTime(convertFromUtc(utcNow(), 'India Standard Time'), 'MM-dd'))


9). Add "Apply to each" loop and enter previous step output as input value.

10). Add an action "Compose" and add Adaptive Card payload in the inputs parameter (refer step 12).

11). Now, add an action "Post card in a chat or channel" and "Send an email (V2)".
Add mandatory parameter values as shown in below image.


12). Open Adaptive Cards Designer portal and create the Adaptive card design according to your requirements.

Once Adaptive Card design is complete. Click on "Copy card payload" and paste it into the  Adaptive Card parameter value (Step 11)


Then add dynamic values for the user display name and user photo (yellow highlighted).

Happy Birthday - CARD PAYLOAD
{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "body": [
        {
            "type": "TextBlock",
            "text": "🎂 Happy Birthday 🎂",
            "wrap": true,
            "id": "happyBirthdayCard-Title",
            "horizontalAlignment": "Center",
            "size": "ExtraLarge",
            "weight": "Bolder",
            "fontType": "Monospace"
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "Image",
                            "id": "happyBirthdayCard-Image",
                            "url": "https://cdn0.iconfinder.com/data/icons/
                                    birthday-sticker/100/14_happy_birthday_
                                    balloon_event_celebration-1024.png",
                            "separator": true,
                            "horizontalAlignment": "Center"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Hi Vikas Bansal,",
                            "wrap": true,
                            "id": "happyBirthdayCard-MailHeader",
                            "weight": "Bolder",
                            "size": "Medium"
                        },
                        {
                            "type": "TextBlock",
                            "text": "We extend our warmest wishes for a
                                     wonderful birthday and a year filled
                                     with cherished memories. Best regards
                                     from all of us.",
                            "wrap": true,
                            "id": "happyBirthdayCard-MailBody"
                        },
                        {
                            "type": "TextBlock",
                            "text": "Team HR",
                            "wrap": true,
                            "id": "happyBirthdayCard-MailFooter"
                        }
                    ],
                    "id": "happyBirthdayCard-Column",
                    "verticalContentAlignment": "Center"
                }
            ],
            "separator": true
        }
    ],
    "id": "happyBirthdayCard"
}


13). Complete flow with all the actions will look like below.



Now it's time to test the flow. Manually run the flow and wait for sometime.

Adaptive Card output for Teams desktop application.



Adaptive Card output for Teams web application.



Adaptive Card output for Outlook web application.



Refer Adaptive Card blog series:
Adaptive Card: Power Automate send welcome message when new team member added
Adaptive Card: Power Automate send birthday greetings to team members
People Picker in Adaptive Cards
Adaptive Card: Send Form using Adaptive card in MS Teams to group members


I hope this will help all of you! 🧲
Feel free to provide feedback.


🚀 "Happy Coding" 🚀

Friday, 19 July 2024

Adaptive Card: Power Automate send welcome message when new team member added

In this blog, we will be learning about Adaptive Cards and how to send a welcome message automatically to Team's channel when a new member is added to the team.

What is Adaptive Card?

Adaptive cards are a platform-agnostic method of sharing and displaying blocks of information without the complexity of customizing CSS or HTML to render them. Adaptive Cards are authored in JSON format enabling developers to exchange UI content in a common and consistent way with cloud apps and services integrations.

Create Flow

1). Sign in to Power Automate

2). Open the flow, click on the Create option, and select "Automated Cloud Flow".

Enter Flow name.
Choose the flow trigger as "When a new team member is added".
Click on the Create button.


3). Enter the team name in trigger action.

4). Initialize variable of string type.


5). Add an action "Get user profile (V2)" and enter User (UPN) value as trigger output User ID.

6). Add an action "Get user photo metadata" and enter User (UPN) value as trigger output User ID.


7). Add a condition to check if user "Has photo" or not.

a) If Yes, add an action "Get user photo (V2)" and enter User (UPN) value as trigger output User ID. Set variable value as base64 encoded image content (received from above).

concat('data:image/png;base64,',body('Get_user_photo_(V2)')?['$content'])

b) If No, set variable value as default/fallback image absolute hyperlink.


8). Now, add an action "Post card in a chat or channel".
Add mandatory parameter values as shown in below image.


Now we will discuss how to create Adaptive Card parameter value.

9). Open Adaptive Cards Designer portal.

Select host app as "Microsoft Teams" and Target version as 1.4


⊛ Note

  • Adaptive Card payload size in Microsoft Teams should be less than 28KB. This limit applies to the entire card, including all its elements and actions.
  • The latest Target version didn't work, but version 1.4 worked in my testing.
  • Image element:
    • URL's must start with https and and ends with file extension like JPEG, PNG, GIF.
    • URL can be an absolute hyperlink to image or base64 encoded file contents.
    • Emoji's can render differently based on the device's OS (Windows, Android, iOS) and even vary in web browsers.


10). Click on "New card" and select Blank Card template. However you can use existing available templates as well and modify them as per your requirements.


11). Select the required elements from the Card Element left pane. Then drag and drop onto the Card Design area.


12). Set the Card element properties. Currently, we will set the static details and later on add dynamic data from flow itself.


13). Once Adaptive Card design is complete. Click on "Copy card payload" and paste it into the  Adaptive Card parameter value (Step 8)

Then add dynamic values for the user display name and user photo (yellow highlighted).

Welcome Message - CARD PAYLOAD
{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4",
    "body": [
        {
            "type": "TextBlock",
            "text": "Greetings and welcome to the team!",
            "wrap": true,
            "id": "welcomeCardTitle",
            "horizontalAlignment": "Center",
            "fontType": "Monospace",
            "size": "Large",
            "weight": "Bolder",
            "color": "Accent"
        },
        {
            "type": "Image",
            "url": "https://cdn1.iconfinder.com/data/icons/
                    user-pictures/101/malecostume-64.png",
            "altText": "Vikas Bansal",
            "horizontalAlignment": "Center",
            "id": "welcomeCardProfileImage",
            "separator": true,
            "style": "Person",
            "size": "Medium"
        },
        {
            "type": "TextBlock",
            "text": "Vikas Bansal",
            "wrap": true,
            "fontType": "Default",
            "size": "ExtraLarge",
            "weight": "Bolder",
            "color": "Dark",
            "horizontalAlignment": "Center",
            "id": "welcomeCardDisplayName"
        },
        {
            "type": "TextBlock",
            "text": "Welcome aboard to our team, it's truly incredible to
                     have a fresh and talented new member on board!
                     Through our collaboration, we are poised to elevate
                     the company to new heights. 🚀🚀",
            "wrap": true,
            "id": "welcomeCardDescription",
            "size": "Small",
            "weight": "Default",
            "separator": true
        },
        {
            "type": "Image",
            "id": "welcomeCardDescriptionImage",
            "horizontalAlignment": "Center",
            "url": "https://cdn1.iconfinder.com/data/icons/
                    welcome-greeting-illustration/3000/Welcome-03-256.png"
        }
    ],
    "id": "welcomeCard"
}


14). Complete flow with all the actions will look like below.



Now its time to test the flow. Add an user in the Teams as provided in the flow and wait for sometime.

Adaptive Card output for Teams desktop application.



Adaptive Card output for Teams web application.





Refer Adaptive Card blog series:


I hope this will help all of you! 🧲
Feel free to provide feedback.


🚀 "Happy Coding" 🚀