Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
Based on the information you provided, I understand you are building a bidirectional presence synchronization between your telephony platform and Microsoft Teams. You've noticed that while transitioning between Available and Busy works, you cannot set Away or DND, nor can you override a user's manual Teams status back to Available.
In Microsoft Teams, application presence sessions (setPresence) and user-preferred/manual presence (setUserPreferredPresence) are two completely different mechanisms. Here is how the platform architecture handles this and the recommended approach for your telephony integration:
Teams aggregates presence from multiple sources using a strict hierarchy: User-preferred status > Session-level status. Within the session-level hierarchy, the priority order is: DoNotDisturb > Busy > Available > Away.
Available to Busy transitions work because setPresence is designed exactly for session-level changes. You cannot override a manual status on Teams because a user's preferred presence has a higher precedence than your application's session-level presence. If a user manually sets themselves to Away/Busy/DND, your app cannot force them back to Available.
-Recommended API Strategy for Telephony Integration
- For Active Calls: You should use
setPresenceto publish temporary call states (such asBusy/InACallorBusy/InAConferenceCall). This endpoint sets an application session state that requires your application client ID as thesessionId.
POST /users/{id}/presence/setPresence
Content-Type: application/json
{
"sessionId": "{application-client-id}",
"availability": "Busy",
"activity": "InACall",
"expirationDuration": "PT1H"
}
When the call ends: Use setPresence to return your application session to Available / Available. Note that this will not override a user-preferred manual state due to the precedence rules.
- For Telephony DND: If DND is meant to represent a real user preference that overrides everything else, you should use
setUserPreferredPresence:
POST /users/{id}/presence/setUserPreferredPresence
Content-Type: application/json
{
"availability": "DoNotDisturb",
"activity": "DoNotDisturb",
"expirationDuration": "PT8H"
}
- For Away States:
Away / Awayis supported by both endpoints. However, because Away has the lowest session-level precedence, if you usesetPresence, any other active session (like a desktop client) will win in the aggregated state. If it represents a true user preference, usesetUserPreferredPresence.
Please refer the following document:
presence: setUserPreferredPresence
Manage presence state using the Microsoft Graph API
Please let me know if you need any further details!
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click ""Comment"".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.