Pages Menu
TwitterRssFacebook

Posted by on Jul 10, 2020 in Development, Microsoft Teams | 0 comments

Subscribe to changes in Microsoft Teams presence – Now in Preview!

Subscribe to changes in Microsoft Teams presence – Now in Preview!

We’ve been able to query Microsoft Graph for the presence state of Microsoft Teams users for a while, but only via a simple GET call. There hasn’t been a way to subscribe to changes, other than polling that GET call every minute or so.

Now, however, there is a way to do this! You can subscribe to change notifications for presence via a new presence subscription API which is now in Public Preview.

This subscription is similar to other Graph webhooks. See my blog post: How to: Use the new Webhooks for Microsoft Teams Channel & Chat Messages for more details on how to use them generally.

This doesn’t replace the existing GET method which can you continue to use. This is simply a nicer way to be told about changes to presence state.

Note: the only supported permission model here is Delegated user permissions. This means that your application needs to have a token from a logged-in user, meaning it can’t be used for head-less applications where there is no user involved. This is no different from the existing GET call.

Similar to all other Microsoft Graph change notification subscriptions – the subscription only lasts a set amount and must be renewed otherwise it will expire. For presence, a subscription lasts 1 hour if not renewed. After that time, you won’t be notified of any changes to presence unless you create a new subscription.

If you want to know about the presence of multiple users then you don’t need to maintain a subscription for each user. Instead you can create a single subscription which can cover up to 650 users:

  • For a single user, set the “resource” property to “/communications/presences/[id]” where [id] is the User GUID of the user you’re want to track presence for
  • For multiple users, set the “resource” property to “/communications/presences?$filter=id in ([id1],[id2]…)” where each [id] is a different User GUID to track

 

This new change notification will be really helpful to developers building applications that need to display up to date Teams presence information, or use that information to react to presence state changes. It’s also interesting to see Microsoft investing development effort in alternative ways of accessing information from Graph which will, at scale, reduce load on the whole system. By providing mechanisms like this for developers, it means that those developers aren’t writing code to continuously poll for changes all the time. It also enables them to act more aggressively on throttling GET requests if they can provide alternate methods that achieve the same outcome.

Ref: Get notified of presence changes – the Microsoft Graph presence subscription API is now available in public preview

Post a Reply

Your email address will not be published. Required fields are marked *

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

This site uses cookies to help make this website better. By continuing to use this site we’ll assume you’re OK with that (implied consent).