When a new team member is added
Table of contents:
With this new trigger you can add create a new level of governance for your Microsoft Teams. Especially when speaking about the on-boarding users or other automated processes for newly added Teams members.
Step by step
The trigger is nothing complex. Simply, create new automated flow, use that trigger from Microsoft Teams group, select a Team that the flow should monitor and that’s it.
Note: the only outcome of this trigger is User Id, of the added user.
Now what you do after the trigger is totally up to you. Let me describe my scenario, I hope it will be inspiring for you.
- User is added to a Team, that has its public and private channels.
- Before user is added to private channels, they must accept NDA rules.
- To do this, after they are added to a Team, process sends them Adaptive Card with all the information plus a button to express confirmation (or not).
- If they confirm, a POST to Microsoft Graph API automatically adds them to a specific private channel.
And that’s it. Please, watch the screencast where I describe the scenario in details:
Calling Graph API
To call Microsoft Graph API endpoint, to add user into a private channel, I am using the following URI:
https://graph.microsoft.com/beta/teams/[TEAM ID]/channels/[CHANNEL ID]/members/
Body of the POST request is the following:
{ "@odata.type": "#microsoft.graph.aadUserConversationMember", "roles": [ "member" ], "user@odata.bind": "https://graph.microsoft.com/beta/users/[USER ID FROM TIRGGER]" }
Described approach is following documentation for beta version of Graph API: https://docs.microsoft.com/en-us/graph/api/conversationmember-add?view=graph-rest-beta&tabs=http.
To configure authentication you need to register new app in Azure AD, that has the following permissions granted (and admin consent for them). Preferably on the application level:
- ChannelMember.ReadWrite.All,
- Group.ReadWrite.All,
- Directory.ReadWrite.All
Adaptive Cards…
All cards I used for the demo were authored using https://adaptivecards.io/designer. If you’re interested more about the technology itself, please see my other posts: Register response from custom Adaptive Cards sent from Power Automate to Teams
That’s it! Thanks! If you have any questions please leave them in comments below.