You can now SUBSCRIBE for changes to Team Chats and Private Chats (rather than polling). But, you might have to pay for it…
Big news for anyone writing applications that need to know when things change in Microsoft Teams. Up until now it’s been quite a complicated process to keep on top of new messages in team channels, or in chats. That’s because the only method of accessing the data was to use a GET method, which returned all data. There aren’t any deltas or ways to just get “message I don’t already know about” so developers had to bring back all the data and then work through it, looking for changes. That’s OK when it’s just new messages, but when you factor in replies and reactions to old messages as well, it’s a fairly involved process. At scale, it’s also a lot of data, meaning that applications get throttled, making the whole thing even more complicated.
- subscribe to be notified about messages in a specific channel, for a given team ID and channel ID. This subscription covers new messages, replies, edits, reactions and deletes.
- subscribe to be notified about messages in a specific 1:1 or group chat, for a given chat ID. This subscription covers new messages, replies, edits, reactions and deletes.
- subscribe to all messages in a tenant. This is a very exciting new type of subscription that I’ve been asking for since I can remember!
- subscribe to all chat messages in a tenant. Again, very exciting
This subscription approach isn’t new, there are other workloads in Microsoft Graph which use this. The general idea is that you tell Graph what you want to be notified about, and where it should notify you (by specifying a URL). Then, every time something happens, Graph will call that URL with the details of what happened. This means there is no longer a need to poll for changes, and iterate through data that might or might not be new – applications can do an initial poll and then just get “drip fed” new changes as they happen.
Free for now…
The last two subscriptions in that list (the tenant-wide ones) are currently free to use, in the same way that other subscriptions are. There is, however, a specific note against these two subscriptions that when they reach GA status, charges may apply.
Exciting and Sensible
I think this is great news. These tenant-wide subscriptions are the right way for developers to access Teams data at scale, and will help people build better applications to integrate with Microsoft Teams.
I’ve been asking since the UCMA days for a way to access data at the tenant level, and it’s very exciting to see this now coming. I’m looking forward to seeing how we can use this new method of accessing Teams data.
Look out for more blog posts in the coming days and weeks about how to set up these subscriptions – there are some interesting and unique new features that the Teams team have implemented.
In the meantime, there is a sample application you can look at.