Public preview of Microsoft Graph Presence API was published on December 2019. With current public preview, it is possible to get user’s own presence, presence of someone else and presence of multiple users with a single call. Getting a presence of signed-in user is retrieved by doing a HTTP GET call to either /beta/me/presence
endpoint and /beta/users/<user- id>/presence
endpoint for other users. Call returns a object with user’s availability and activity.
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('476594e4-ee42-4152-b464-c01966b50fe2')/presence/$entity",
"availability": "Away",
"activity": "Away",
"id": "476594e4-ee42-4152-b464-c01966b50fe2"
}
Getting a presence of multiple users is done by HTTP POST call to Microsoft Graph’s communication API presence endpoint /beta/communications/ getPresencesByUserId
with body containing ids of users, like below.
{ "ids": ["fa8bf3dc-eca7-46b7-bad1-db199b62afc3", "66825e03-7ef5-42da-9069-724602c31f6b"] }
And call returns an array user presence information.
{ "value": [ { "id": "fa8bf3dc-eca7-46b7-bad1-db199b62afc3", "availability": "Busy", "activity": "InAMeeting" }, { "id": "66825e03-7ef5-42da-9069-724602c31f6b", "availability": "Away", "activity": "Away" } ] }
Possible returned values of availability are Available, AvailableIdle, Away, BeRightBack, Busy, BusyIdle, DoNotDisturb, Offline, PresenceUnknown
and for activity Available
, Away
, BeRightBack
,Busy
, DoNotDisturb
, InACall
, InAConferenceCall
, Inactive
,InAMeeting
, Offline
, OffWork
,OutOfOffice
, PresenceUnknown
,Presenting
, UrgentInterruptionsOnly
Currently beta API can be access only with user delegated permissions. Presence.Read
permission allows reading presence of signed-in user and Presence.Read.All
allows reading presence of all users in the directory.
More information about presence API can be found here: https://docs.microsoft.com/en-us/graph/api/resources/presence?view=graph-rest-beta
Example app – displaying presence of team members on Teams
Example app is a SharePoint Framework web part, which displays availability and activity of Office 365 Group members.

Availability is displayed as an ellipsis, where availablity values of the Graph API are mapped to Office UI Fabric’s PersonaPresence
values, and activity is shown as text. Information is retrieved by making two Graph API calls. First needed group id is retrieved from legacyPageContext
.
this.props.context.pageContext.legacyPageContext['groupId'];
First call is to get members of the current Office 365 Group by calling /groups/<group-id>/members
endpoint. Returned member ids are the passed to presence endpoint of communications API, /communications/ getPresencesByUserId
. Returned values are mapped with user information and displayed with Office UI Fabric’s Persona control.
Web part requires two API permissions to Microsoft Graph.
"webApiPermissionRequests": [{"resource":"Microsoft Graph","scope":"Presence.Read.All"},{"resource": "Microsoft Graph","scope": "Group.Read.All"} ] }
Example web part can be used on modern SharePoint page on Office 365 Group connected team sites and it can be added as a Microsoft Teams tab.
Afterword
Beta API already works nicely and status is updated almost instantly, when status is changed on Teams. Teams status is also the master. So when you set your status explicitly for example to “Be right back”, it’s returned until you change or reset your status. I also noticed that status based on calendar events is updated with some delay.
I didn’t test Skype for Business status, because I’m not using it anymore.
Source codes for the example web part can be found here: https://github.com/mpaukkon/SharePoint/tree/master/spfx-webparts/react-team-presence
This looks awesome…not being much of a programmer I’m a bit confused how to deploy this though…any tips/instructions?
LikeLiked by 1 person
You can get built App Package here: https://github.com/mpaukkon/SharePoint/blob/master/spfx-webparts/react-team-presence/sharepoint/solution/react-team-presence.sppkg
1. Upload package to app catalog and deploy
2. Approve Graph API permissions on API access page on SharePoint Admin Center
3. Allow Team Presence Web Part on Teams App Catalog
4. Add it as a tab.
LikeLike
Hey I’ve just implemented this, and it’s working great in each tabs in Teams. It’s showing current statuses of all the group members – just not their thumbnail image or their name…
Did I do something wrong, or does the code need an update? Thank you for this!
LikeLike
I’ll check this out and get back to you.
LikeLike
Hi Matti, Great stuff but i have a small question I am able to install it and it shows up as an available app, but adding it to tabs fails. I can choose a team and the on the final dialog “publish to the team” and Save button. The save button is still grayed out. Any clues on what that might bee?
LikeLike
Is this able to be be simply modified to also display the status message of the user as well?
LikeLike