Pages Menu

Posted by on Jul 2, 2021 in Development, Microsoft Teams

Know when your Teams settings change with new API for changes to the structure of teams and channels

Know when your Teams settings change with new API for changes to the structure of teams and channels

I’ve been talking about change notifications in Microsoft Graph for a while, including the ability to subscribe to messages in Teams channels and chat.

If you aren’t sure what I’m talking about, here’s a little part of a previous video about Teams Platform Development that explains what change notifications are (7m 58s):

However, what’s been missing has been the ability to subscribe to changes in the structure of teams and channels. There hasn’t been any way to know that, for instance, guest access just got turned on in the HR channel đŸ˜±, other than polling all teams periodically and comparing them with previously collected copies of the structure.

That changes now though, with the introduction of additional change notifications to support changes to either specific teams and channels, or teams and channels across the entire tenant. These last two notifications really feel like they have been created with compliance software in mind.

Today, all of these new notifications are in Beta. This means you really shouldn’t use them in Production, because they aren’t supported and aren’t guaranteed to be stable. APIs in beta do move around – such as the userPurpose API changing last week.

What sorts of things can you now do?

With this change, it’s no longer necessary to poll for changes to the structure of teams and channels. This means that developers who want to notify or take action when team names change, or membership is updated, or access policies are changed, can do so without a complicated and brittle mechanism to continually check back to see if anything has changed.

In the announcement blog post for these features, Microsoft suggest the following scenarios:

  • Automating rules to enforce best practices for team naming conventions in your organization to ensure they are easy to discover; for example, Finance – Approvals, or Class of 2021 – 8th Grade Chemistry.
  • Automating new member onboarding, by granting access to resources and onboarding materials without human intervention.
  • Automating appropriate resource access, by revoking access to resources when someone leaves a team.
  • Periodically prompting guests to review and accept your organization-specific privacy and data compliance policies to continue their team membership.
  • Ensuring only users with certain clearance are part of a particular team.

These are also good for Microsoft too. They don’t really want developers writing polling code against their API and hitting throttling limits at scale and by introducing change notifications for things that developers are checking for they can reduce their own load as well as offering developers a nicer way of accessing the same data.

What are the new change notification subscriptions?

Here are the new resources you can subscribe to. You specify these are the resource field when creating a new resource. For all of these you can subscribe to one or more changeType values of: “created”, “deleted”, “updated” :

  • /teams/{team-id} – to receive notifications about changes to the structure of a specific team
  • /teams/{team-id}/channels – to receive notifications about changes to all channels in a specific team
  • /teams – to receive notifications about changes to all teams in the tenant
  • /teams/getAllChannels – to receive notifications about changes to all channels in all teams in the tenant

By default, if you subscribe to these notifications then every time they are triggered and your webhook URL is called, the payload will include a reference URL to fetch the actual data. However, all of these new resources also support including resource data in the payload. This is specified when setting up the subscription and saves the consuming application from a second trip to download the data – instead it is specified in the initial notification payload.

More information, including subscription examples here: Get change notifications for teams and channels using Microsoft Graph – Microsoft Graph | Microsoft Docs

Anything else?

Microsoft are all-in on no-code and low-code solutions at the moment. There are already several triggers for Power Automate which can be used to react to changes in Microsoft Teams, but right now they are limited to members being added and removed, and around keywords and messages:

Power Automate Teams triggers

There’s no mention of this in the announcement, but I think that it would be a logical step that, now there is an internal mechanism to notify in response to settings being changed, we will start to see some Power Automate triggers for these types of notifications. That would unlock all sorts of Teams management flows to alert when settings are changed or new channels are created. Would you like an email for every new team that was created in your tenant? That might end up being a 2-minute Power Automate function if these new notifications make their way into the Power Platform. We’ll have to wait and see.

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

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.