Microsoft Graph API – User Presence Endpoints

In this article I am going to explain about the new presence API endpoints introduced by Microsoft Graph API team. We can use these endpoints to read availability(Possible values are Available, AvailableIdle, Away, BeRightBack, Busy, BusyIdle, DoNotDisturb, Offline, PresenceUnknown) and activity information(Possible values are Available, Away, BeRightBack,Busy, DoNotDisturb, InACall, InAConferenceCall, Inactive,InAMeeting, Offline, OffWork,OutOfOffice, PresenceUnknown,Presenting, UrgentInterruptionsOnly.) about the current logged in user or any other users (as long as we have proper permissions to access that user/s).

In order to access the presence API, we will need to configure Presence.Read and Presence.Read.All permission scopes in Azure AD Application. Unfortunately, application permission type is not currently supported for these endpoints but feel free to vote for this idea in the user voice site.

Disclaimer: Presence API endpoints are currently under the beta version. That means these endpoints are subject to change and not recommended to use in production.

Use case 1 – Get current user presence details

MethodGET
Endpointhttps://graph.microsoft.com/beta/me/presence
HeaderAuthorization  Bearer {token}
Requesthttps://graph.microsoft.com/beta/me/presence
Response“id”: “44285e03-f57e-42da-9069-724602c31f6b”, “availability”: “DoNotDisturb”, “activity”: “Presenting”

Use case 2 – Get other user’s presence details

MethodGET
Endpointhttps://graph.microsoft.com/beta/users/{userid}/presence
HeaderAuthorization  Bearer {token}
Requesthttps://graph.microsoft.com/beta/users/55285e03-f57e-42da-9069-724602c31f6b/presence
Response“id”: “55285e03-f57e-42da-9069-724602c31f6b”, “availability”: “DoNotDisturb”, “activity”: “Presenting”

Use case 3 – Get more than one user presence details

MethodPOST
Endpointhttps://graph.microsoft.com/beta/communications/getPresencesByUserId
HeaderAuthorization: Bearer {token} Content-Type: application/json
Requesthttps://graph.microsoft.com/beta/communications/getPresencesByUserId
Body{ “ids”: [“33285e03-f57e-42da-9069-724602c31f6b“, “55285e03-f57e-42da-9069-724602c31f6b“] }
Response{             “value”: [{                                     “id”: “33285e03-f57e-42da-9069-724602c31f6b“,                                     “availability”: “Busy”,                                     “activity”: “InAMeeting”                         },                         {                                     “id”: “55285e03-f57e-42da-9069-724602c31f6b“,                                     “availability”: ” DoNotDisturb “,                                     “activity”: ” Presenting ”                         }             ] }

Hope you found this article helpful! Let me know if I might have missed anything or can be done better.

2 thoughts on “Microsoft Graph API – User Presence Endpoints

  1. Hi Joseph. I’m currently building a web chat solution for our customers (who do not have Teams). Our internal employees are all using Teams and I want to display their status to our customers who want to chat.

    Would this use case require application permission or is this supported with your use case 2? If I know the user ID of all of our Teams users, am I able to make the https://graph.microsoft.com/beta/users/{userid}/presence request as a customer in my scenario?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.