alert

Create new group alert using Power Automate

Do you want to know when a new group has been created with for example Microsoft Teams? How do you create a new group alert?

Create a new flow

Ideally we would want a flow to trigger on the creation of a new group. But there is now trigger nor there is an action to list all groups.

Create new group alert using Power Automate Microsoft Power Automate

The closest thing available is an action that lists my groups.

We need a better solution. Keep reading!

In my flow I’m going to start with trigger that schedules the flow to run every hour. If you need the alerts to come in quicker then simply adjust the schedule and the filter later on in this post.

Create new group alert using Power Automate Microsoft Power Automate

Configure an App registration

Like with my posts about Excel and Microsoft Graph, I’m using an Azure App Registration to look after the access to Microsoft Graph end points.

Create new group alert using Power Automate Microsoft Power Automate

Within Azure I go through the App registration process.

Create new group alert using Power Automate Microsoft Power Automate

Then the important part, the Group.Read.All scope is selected and once selected the Grant admin consent is completed.

Create new group alert using Power Automate Microsoft Power Automate

now we are ready to build our flow.

I’ve created 3 compose boxes again, to hold my Secret, Tenant ID and Client ID, that can be collected form my application registration in Azure.

Create new group alert using Power Automate Microsoft Power Automate

Then to make my job easier, I’m extracting the access token from the HTTP request using the following expression:

body('HTTP')?['access_token']
Create new group alert using Power Automate Microsoft Power Automate

Then the next HTTP request to the MS Graph endpoint that gives me all the groups. In this call you should consider filtering just the latest groups that have been created, however for this post I’m going for the easier to configure approach.

I’m going to use a filter action.

Create new group alert using Power Automate Microsoft Power Automate

In the following filter I’m using the following expression in the From:

body('HTTP_2')?['value']

Then in the left hand side of the filter

item()?['createdDateTime']

And on the right hand side using the formatDateTime function, I’m selecting the recently created groups.

formatDateTime(addHours(utcNow(), -1), 's')
Create new group alert using Power Automate Microsoft Power Automate

Now I will have an array of new groups. Note that if you want to run the alerts more frequently you will have to adjust the code in the above filter.

New Group Alert emails

Now the final step is to send out new group alert emails to the people who need to know.

New group Alert Emails

Leave a Reply

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

Archive
%d bloggers like this: