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
Method | GET |
---|---|
Endpoint | https://graph.microsoft.com/beta/me/presence |
Header | Authorization Bearer {token} |
Request | https://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
Method | GET |
---|---|
Endpoint | https://graph.microsoft.com/beta/users/{userid}/presence |
Header | Authorization Bearer {token} |
Request | https://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
Method | POST |
---|---|
Endpoint | https://graph.microsoft.com/beta/communications/getPresencesByUserId |
Header | Authorization Bearer Content-Type: application/json{token} |
Request | https://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.