"setPresence" graph API- expirationDuration time out value no effect, always considering default expiration of 5 minutes.

Shashikant Sharma 85 Reputation points
2025-03-10T07:02:00.63+00:00

I have to post it again as I did not get any answers on me prev post.

I Am unable to create a presence session for the user for customized expirationDuration parameter. I have tried to set its value as 'PT1H', 'PT4H', 'PT50M', but nothing is working, it seems like MS Graph always considering a default value for expirationDuration and app behaving as follows:

"Main application sets the presence session as Available/Available, the state would change to Available/AvailableInactive in 5 minutes with the first timeout, then Away/Away in another 5 minutes with the second timeout.". Creating session as follows:

const setPresence = { sessionId: xxxx-xxxx-xxxx-xxxx, // registered azure app id availability: 'Available', activity: 'Available', expirationDuration: 'PT1H', }; const res = await CommonGraphClient.myInstance.api(/users/${userId}/presence/setPresence).post(setPresence);

Once session is created, we are calling setUserPreferredPresence to set the status of the user. User can select their desired status from a drop down from the main UI as

'Available','Busy','DoNotDisturb','BeRightBack','Away', 'OffWork',

const presence= {

sessionId: xxxx-xxxx-xxxx-xxxx, // registered azure app id,

availability: userPresence, // presence status selected from UI

activity: xxxx,//'Available','Busy','DoNotDisturb','BeRightBack','Away', 'OffWork'

, expirationDuration: 'PT1H', };

const res = await CommonGraphClient.myInstance.api(/users/${userId}/presence/setUserPreferredPresence).post(presence);

But once the session expires, User status is set to 'Away" and now it cannot be changed to any other status by user from Combo.

Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,642 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Nivedipa-MSFT 3,421 Reputation points Microsoft External Staff
    2025-03-11T09:03:46.42+00:00

    @Shashikant Sharma - This is by design behavior. If the session expires, the user's status will revert to Away, and they won't be able to change it until a new session is created.

    Thanks, 

    Nivedipa 

    -----------------------------------------------------------------------------------------------------------

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.