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

%3CLINGO-SUB%20id%3D%22lingo-sub-1514522%22%20slang%3D%22en-US%22%3ESubscribe%20to%20changes%20in%20Microsoft%20Teams%20presence%20%E2%80%93%20Now%20in%20Preview!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1514522%22%20slang%3D%22en-US%22%3E%3CP%3EWe%E2%80%99ve%20been%20able%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fpresence-get%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dhttp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Equery%20Microsoft%20Graph%20for%20the%20presence%20state%20of%20Microsoft%20Teams%20users%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efor%20a%20while%2C%20but%20only%20via%20a%20simple%20GET%20call.%20There%20hasn%E2%80%99t%20been%20a%20way%20to%20subscribe%20to%20changes%2C%20other%20than%20polling%20that%20GET%20call%20every%20minute%20or%20so.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENow%2C%20however%2C%20there%20is%20a%20way%20to%20do%20this!%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EYou%20can%20subscribe%20to%20change%20notifications%20for%20presence%20via%20a%20new%20presence%20subscription%20API%20which%20is%20now%20in%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EPublic%20Preview%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20subscription%20is%20similar%20to%20other%20Graph%20webhooks.%20See%20my%20blog%20post%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fblog.thoughtstuff.co.uk%2F2020%2F01%2Fhow-to-use-the-new-webhooks-for-microsoft-teams-channel-chat-messages%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHow%20to%3A%20Use%20the%20new%20Webhooks%20for%20Microsoft%20Teams%20Channel%20%26amp%3B%20Chat%20Messages%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efor%20more%20details%20on%20how%20to%20use%20them%20generally.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20doesn%E2%80%99t%20replace%20the%20existing%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fpresence-get%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dhttp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGET%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Emethod%20which%20can%20you%20continue%20to%20use.%20This%20is%20simply%20a%20nicer%20way%20to%20be%20told%20about%20changes%20to%20presence%20state.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ERead%20More%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblog.thoughtstuff.co.uk%2F2020%2F07%2Fsubscribe-to-changes-in-microsoft-teams-presence-now-in-preview%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblog.thoughtstuff.co.uk%2F2020%2F07%2Fsubscribe-to-changes-in-microsoft-teams-presence-now-in-preview%2F%3C%2FA%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1514522%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1552522%22%20slang%3D%22en-US%22%3ERe%3A%20Subscribe%20to%20changes%20in%20Microsoft%20Teams%20presence%20%E2%80%93%20Now%20in%20Preview!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1552522%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7960%22%20target%3D%22_blank%22%3E%40Tom%20Morgan%3C%2FA%3E%26nbsp%3BHello%20Tom%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20implemented%20the%20webhook%20and%20it%20works%20great%20!%20notifications%20are%20received%20in%20approx%205%20seconds%20after%20the%20presence%20is%20changed%20!%3C%2FP%3E%3CP%3EMy%20questions%20is%20regarding%20the%20lifecycle%20events.%20I%20registered%20the%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3ElifecycleNotificationUrl%20in%20the%20subscription%2C%20but%20it%20is%20never%20called.%20Meaning%20that%20when%20the%20subscription%20is%20expired%20I'm%20not%20notified%20to%20reactive%20it.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIs%20this%20not%20implemented%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ethanks%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EDirk%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Highlighted
MVP

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.

 

Read More: https://blog.thoughtstuff.co.uk/2020/07/subscribe-to-changes-in-microsoft-teams-presence-now-in-prev...

1 Reply
Highlighted

@Tom Morgan Hello Tom, 

I have implemented the webhook and it works great ! notifications are received in approx 5 seconds after the presence is changed !

My questions is regarding the lifecycle events. I registered the 

lifecycleNotificationUrl in the subscription, but it is never called. Meaning that when the subscription is expired I'm not notified to reactive it.
 
Is this not implemented?
 
thanks
Dirk