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

Including a user photo in an Adaptive Card

Hi

As a proof of concept, I'm trying to build a flow that will post an adaptive card to a Teams channel with my profile mugshot in the message body.

The only components I can find to return my profile image, return the raw content, rather than a URL....is there a way to get this working?

 

2019-03-22_15h28_44.png

 

56 REPLIES 56

Thanks Fraser! Was stuck in this for a long while now. Your answer really helped. This idea worked, I just had to change

 

 

"url": "data&#58image/png;base64,@{outputs('Compose')}",

 

 

 to 

 

 

"url": "data:image/jpeg;base64,@{outputs('Compose')}",

 

 

and it worked fine for me. I wanted to use user profile image in adaptive card(to be displayed on Outlook app) and was able to achieve that.

Adarsh2199_0-1603802471595.png

Anonymous
Not applicable

This worked perfectly for me, thank you!

None of the prior options worked for me. I think due to 302 redirect errors in the 'Send a HTTP Request to Sharepoint' action. The response didn't return any redirected location so I was stuck.

 

"https://teams.microsoft.com/api/mt/apac/beta/users/8:orgid:<user ID>/profilepicturev2?displayname=<display name>&size=HR96x96"

 

What worked for me was to construct the above URL used by Teams for user photos. This includes a user ID (e.g. '3666e81d-07ba-628e-b633-51db53a564c3') that I noticed was included in the output from 'List group members'. Filter this output by 'User Principal Name' = email address of the user (case-sensitive so I used toLower()) to find the relevant member.

toLower(triggerOutputs()?['body/Assigned/Email'])

Thwatered_0-1639438976952.png

in the adaptive card, the user picture is posted via:

Thwatered_1-1639439206068.png

{
"type": "Image",
"style": "Person",
"size": "Small",
"url": "https://teams.microsoft.com/api/mt/apac/beta/users/8:orgid:@{items('Apply_to_each')?['id']}/profilepicturev2?displayname=@{items('Apply_to_each')?['displayName']}&size=HR96x96"
}
Apply to each loop should only have one iteration due to the filter. You could avoid this by writing the filter outputs to variables.
 
When checking, these 96x96 images are only ~9 kB. Thankfully below the 28 kB limit.
 
Edit: also, you may need to edit 'apac' to suit your region if not in Asia Pacific.

 

You Saved me @FraserM ,
Thank you so so much for this solution!

my pleasure 🙂

With the new teams this not work anymore. Anyone konw other options to get teams profile picture?

I have an alternative that works faster, at least that was my experience with the New Teams:

1. Start the flow with the new action, Send an HTTP request to SharePoint  where you have to incluce the required parameter such as the Site Address, make sure that you have the GET method selected, and in the URI:
 _layouts/15/userphoto.aspx?size=S&username= email parameter

2. In the Post Adaptive Card Action, in the message where you have the Payload, use the following text:

"type": "Image",
"url": "data&colon;image/png;base64, ", 
"style": "Person",
"size": "Small"
}   

 

3. Insert this expression just next to the base64, 
body('Send an HTTP request to SharePoint')?['$content']

You should have:

"type": "Image",
"url": "data&colon;image/png;base64,[your expression] ", 
"style": "Person",
"size": "Small"
}   
4. Run the flow and enjoy!!!

McPowerPlatform_1-1702737236138.png

 

Ok but in case the user doesn't have photo i want to show the initials of the name and surname, like teams did. Using this solution, if user doesn't have photo, it will show empty user photo

MichelH
Advocate V
Advocate V

You can test if the "empty image" is send by SharePoint. This is always the same image.

When that happens you can put something else there, e.g. a transparant image.
You would then see the initials in the altText.

MichelH_0-1703058035218.png

 





Great Question!!, what I do is using the Office365 connector using "Get user photo metadata" action,  check if the user has photo, if not, I use a generic image for employees stored in a document library, geting  the base64 content of that image base64( image content) 
Then add a compose action for true or false like this, one using the photo and the other using the generic one.
concat('data&colon;image/png;base64,',base64(GetUserofficephoto))

 

concat('data&colon;image/png;base64,',base64(outputs('genWorker')?['body']))

let me know how this works for you


Sharepoint Get File contentSharepoint Get File contentNew Project (27).png

Flow Condition Update, Has photo is an expression bool(

outputs('Get_user_photo_metadata')?['body/HasPhoto'

 is equal to true

McPowerPlatform_0-1706979297822.png

 



brandtyl
Frequent Visitor

Hi all, 

 

I've tried all of the solutions here, but I couldn't get any of them to work. The profile photo I was trying to use was always too large. In other words, I had exceeded the maximum allowed size for adaptive cards (28KB).

 

I was able to get a profile photo in an adaptive card by doing the following:

 

1. Add the Get user profile (V2) step to your app. The User (UPN) is the email of the employee you want to add to the adaptive card or, in my case, the Created By Email value of a SharePoint item (see Screenshot 1).

 

2. Add a Compose action for the JSON that will go in the Post card in a chat or channel action in the Adaptive Card value (see Screenshot 2).

 

3. Add the code below in the body of the JSON in the Compose action (see Screenshot 3). As you can see, the values for the id, displayName, and userPrincipleName all come from the Get user profile (V2) step (see Screenshot 4). 

 

{
"type": "Component",
"name": "graph.microsoft.com/user",
"view": "compact",
"properties": {
"id": "@{outputs('Get_user_profile_(V2)')?['body/id']}",
"displayName": "@{outputs('Get_user_profile_(V2)')?['body/displayName']}",
"userPrincipalName": "@{outputs('Get_user_profile_(V2)')?['body/userPrincipalName']}"
}
}

 

Hope this helps! By the way, the image is very small, but it's better than nothing. 

 

Screenshot 1

 

Screenshot 2024-02-08 142505.png

 

 

Screenshot 2

 

Screenshot 2024-02-08 145117.png

 

 

Screenshot 3

 

Screenshot 2024-02-08 143653.png

 

 

Screenshot 4

 

Screenshot 2024-02-08 144459.png

I should have realized this sooner, but I was way too excited when I thought I had found a solution. I'm trying to send adaptive cards as the Flow bot. When testing this solution, I was posting as the User. It seems the solution above will only work if you are posting an adaptive card as a User! 

Thank you! Still working on 2k24, 
Using 1.4 in my schema to Teams.

CWRRT
Frequent Visitor

I have tried almost every suggestion without success. I get a bunch of symbols in the input and output fields which may be part of the issue? I tried manually putting in the sharepoint url with user photo path and that at least makes the card post but just has an X image for the photo. I'm using Teams Chat mode with 1.4 and new MS Teams. Tried posting as bot and user.2024-05-17_16-52-29.jpg2024-05-17_16-53-01.jpg2024-05-17_16-53-15.jpg

 

2024-05-17_16-49-42.jpg

@CWRRT you need to specify in the url line that the base 64 data is an image

 

FraserM_1-1716039904556.png

See the image above the code before base64

I tried all of that. Updated screenshots of the actual build vs. results and a screenshot of the current error.Day 2 2.jpgDay 2 Error.jpgDay2.jpg

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (901)