How to display Teams Participants' profile images in the composites #3582
JamesBurnside
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When joining Teams interop today, the Composites show the initials of others users in areas such as the video tile, the participant roster and the chat thread.
However, to make a richer experience you can display the participant's AAD (Azure Active Directory) profile image instead.
This post uses MicrosoftGraph to query and fetch other Teams users' profile images.
Setup
To set user avatars to their AAD profile images you will need a few items setup:
Users.ReadBasic.All
scope.Inject AAD images using Custom Data Injection
Injecting the AAD profile images will be done in two steps:
Fetch and cache profile images from MicrosoftGraph
Microsoft Graph can be queried by either the client-side App or your server App (see Graph Tutorials for more info). This post will use the
@microsoft/microsoft-graph-types
which is a JavaScript wrapper around the MicrosoftGraph API.Convert the image to a URL
The API on the CallCompsite and CallWithChatComposite requires a URL. The response from the MicrosoftGraph is a
Blob
. We can easily convert the blob to a base64 encoded url of the image:Cache the image
To avoid repeatedly fetching user profiles, we want to cache the profile image. For this purpose images will be cheaply cached locally for the lifetime of the app. You may consider caching for longer or shorter depending on your use case.
Display profile images in the Composite
To have the Composites use the profile images for avatars, we use Custom Data Model Injection; specifically the
onFetchAvatarPersonaData
function. First check the user is an AAD user, then fetch the profile image for the user:Try it out and drop a comment if you have any questions!
Beta Was this translation helpful? Give feedback.
All reactions