Thursday, October 28, 2021

Automatically Adding Guests to Your Microsoft Teams Tenant with Power Automate

 

20211019_114456401_iOS.jpg

 

Hi! Welcome back to empowerseries. The goal of this series is to show you all the amazing solutions I have built using Microsoft 365 and Power Platform. I’m Japhlet Nwamu a Gold Microsoft Learn Student Ambassador from Nigeria and an advocate of Microsoft 365, Power Platform and AI. I'm passionate about building tech solutions that utilize the power of AI.

 

As a Gold Microsoft Learn Student Ambassador, I get to work with teams from different countries to organize and support events, bootcamps and hackathons that empower thousands of students globally. One of such bootcamps is Microsoft Africa Development Center West Africa Game Of Learners Clinics. GOL Clinics is an intensive 3-months program aimed at helping university students from all walks of life and beginner developers to level up on .Net, JavaScript, Git, Azure, Software Design and Program Manager Fundamentals. This year, I was part of an amazing team of Gold Microsoft Learn Student Ambassadors and Microsoft employees implementing this program in West Africa.

 

We needed to add over 100 participants to a Microsoft Teams tenant for passing across official information related to the program. Microsoft Teams for now does not support adding multiple users to a Teams tenant at once. Participants could only be added manually. You know what that means? Having to type each participant’s email address and doing that a 100 more times. That was so scary and hectic. And so I thought, what if we could automate this? I’m glad I asked that question. I made some research and yes, I found answers.

 

In this blog, I would show you how to automatically add multiple participants as guests on Microsoft Teams. And did I mention that you would not have to type in their email addresses? Yes, I meant that! Love to see how I created this? Let’s get started.


Before we begin automating, it's important we understand how this system would work. We want participants to fill a form with their full name and email address. With the details in the form, a new user is created on your organization's active directory using the submitted email address and an attached extension. The next step on the flow adds the new user as a guest to the teams tenant. Let's see how this works practically.

Note: You should have admin access to your organization's azure active directory for this system to work.

 

  • First create a simple form using Microsoft Form. Head over to forms.office.com, sign in with your Microsoft account and create a new form with 2 text fields - Name and Email Address.

japhletnwamu_0-1634855046101.png

 

  • Next, head over to Power Automate to start building our automated system. Don't forget to sign in with your Microsoft account. When logged into Power Automate, click on Create and create an Automated Cloud Flow. Give your flow a name - I named mine AddingGuests - and select the trigger When a response is submitted then click Create. When created, you should be redirected to a new page.
  • In the new page, you would find Form Id. Click on the dropdown by the side and select the form you created earlier. This would enable the automated system for that specific form.
  • To get and use the response from the form, we would need to add a new step to our flow. Click on +New step and search for Get response details (Microsoft Forms). When selected, click on the dropdown beside Form Id and select the form you created earlier. For Response Id, select the dynamic content Response Id.

Capture3.png

 

Now we need to add a new step which would automatically create a user in our organization's active directory. But before we do that, we need to add our organization's domain extension to each email address submitted in the form. For example, instead of having japhletnwamu@gmail.com, we want each user to have our organization's domain added as an extension something like this japhletnwamu_gmail.com#EXT#@empowerseries.onmicrosoft.com. To do this, we would need to make use of data processing.

 

  • Click on +New step, search for Compose (Data Operations) and select it. Immediately you do, a new step would be added to your flow. You would notice an Inputs section with a textbox by the side. Click on the textbox by the side and select the dynamic content Email Address. Highlight that field using Ctrl + A and cut out using Ctrl + X.
  • Now click on Add dynamic content then click on Expression. In the textbox that opens up, type in replace() and paste in the details you cut out. The result of that operation should be something like this replace(@{outputs('Get_response_details')?['body/rd0deb8fdbb794696b7dcb4800110f452']}). Remove the signs @, { and } from the operation.
  • Next we need to specify the details we are replacing. After the ] sign, add the following , '@', '_'By adding this, you are telling your automated system to replace the @ sign in the user's email address with an _. The result of both operations should be something like this replace(outputs('Get_response_details')?['body/rd0deb8fdbb794696b7dcb4800110f452'], '@', '_'). When replaced, click Ok.

Capture4.png

 

  • Now we can add a step that would create a user on our organization's Azure active directory. Click on +New step and search for Create User (Azure AD).
  • Sign in to Azure Active Directory with your details if you haven't already. When signed in, fill the empty fields with the right information as shown below:
    1. Account Enabled: Yes
    2. Display Name: Click on Add Dynamic Content and select Name under Get response details
    3. Mail Nickname: GuestUser
    4. Password: Input a default password. Users would be able to change their password later
    5. User Principal Name: Click on Add Dynamic Content and select Outputs under Compose. Then add #EXT#@ and your organization domain name. For example, mine would be #EXT#@empowerseries.onmicrosoft.com
    6. Given Name: This is an optional field, you can leave it blank
    7. Surname: This is an optional field, you can leave it blank

Capture5.png

 

  • Now it's time to add the user to our Microsoft teams tenant. To do so, click on +New step and search for Add a member to a team (Microsoft Teams). Then fill the provided fields.
    1. Team: Select the specific Microsoft teams tenant you want to add participants to
    2. A user AAD ID for the user to add to a team: Click on Add Dynamic Content and select Id under Create user

Capture6.png

 

  • Next save your flow and test Manually.

To test your flow manually you go back to the Microsoft forms you created at the beginning, share the link to the form with random participants to fill in their details and submit. As a reminder, do not forget to change the access to your form to Anyone can respond before sharing with the public or testing out.

 

Microsoft's Power Automate gives you the ability to automate tons of processes without having to learn or write code. Here are some modules on Microsoft Learn that would guide you on your journey:
Automate a business process using Power Automate
Create a business process flow in Power Automate
Automate processes with Robotic Process Automation and Power Automate Desktop
Get started with Power Automate Desktop

Get started with Power Automate buttons
Build custom connectors for Power Automate
Build expertise with Power Automate Desktop

Integrate SharePoint and Power Automate
Work with different technologies in Power Automate Desktop

Work with Power Automate Desktop
Implement advanced logic in Power Automate Desktop

 

As a reminder, don't forget to reach out to me on LinkedIn or Twitter if you need some help while building or having some issues along the way.

Posted at https://sl.advdat.com/3Cpb8O7