I will show you a quick example of how to set up a service-to-service custom connector in Power Automate (MS Flow), which works with Microsoft Teams.
In my previous blog, I have shared how programmatically we can generate MS Teams meeting. Check out here: https://vikrantsdynamicsblogs.wordpress.com/2020/03/28/programmatically-create-the-teams-meeting/
In this blog you will learn, how to Automate MS Teams Meeting in Power automate without writing code.
To achieve this in Power automate we don’t have an inbuilt connector, which communicates with Graph API and generates Teams Meeting.
To overcome this problem we have the option to create a custom connector.
We can achieve this by doing below simple steps,
Let’s start step by step,
Register an Application and add permissions at the Azure portal.
To use Microsoft Graph (connects you to MS Teams), you need a registered application with an identity provider. Bunch of reasons behind this (read original thoughts here: https://www.oauth.com/oauth2-servers/background/), but as a summary: it makes life more secure and provides an extra layer to control permissions.
In Azure AD, you can register your application either as a web or a native app. Go with a web application, as that allows the service-to-service scenario.
Please follow below link for more info to register application: https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
Once the app is registered, save Client ID and Client secret, we require this in future steps.
Now, hit the “API permissions” tab, and add Microsoft Graph with at least the “OnlineMeeting Read and write” permission.
Don’t forget to grand admin consent to newly added permission. (Azure admin will help you in this case).
Create a Custom Connector.
In the second step, log in to MS Flow: https://flow.microsoft.com/
Then on the left navigation, click on Data and then select Custom connectors, on top right corner you will see ‘+ new custom connector’ option, use it and create a blank connector.
(As a license, you need either: Flow Plan 1 // Flow Plan 2 // O365 Business Premium // a trial version)
Then provide the connector name and the properties you are required to fill are as follows.
Now, while creating connector security is the most important part.
Let’s move to the security tab and the properties you are required to fill are as follows,
Once you filled up all required fields then click on create a connector. Redirect URL will get auto-populate.
Once the Redirect URL gets auto-populate, copy it and add it in our azure application under the Authentication tab.
This is the global redirect URL you can use: https://global.consent.azure-apim.net/redirect/
Our connector is created successfully, now time to setup the connector’s actions.
To setup actions, navigate to the definition tab and follow the below steps,
{
"startDateTime":"2020-05-09T14:30:34.2444915-07:00",
"endDateTime":"2020-05-09T15:00:34.2464912-07:00",
"subject":"User Token Meeting11111"
}
Once you click on Import, you will see a new request is created with request URL, headers and request body, as below.
Next, move to the Test tab and click on a new connection, it will prompt one login screen, provide your credentials.
Provide start time, end time and subject of the meeting and click on Test operation, In Success response, you will able to see the meeting is generated with Meeting JoinUrl.
Create MS Flow using Custom connector.
Now the last and final step is how to use this connector in your flow.
To create flow navigate to https://make.powerapps.com/ and create blank flow as below.
Select the manual trigger and create 3 parameters as start time, end time, and subject. (For demonstration I am creating a manual trigger, you can trigger it on any action based on your requirements).
Then click on a new step, under the custom tab our newly created connector will get visible.
Select our connector and select the Create Teams Meeting’ action. (once you add multiple actions in your connector, automatically those will reflect here).
After selecting an action, then we have to setup dynamic values in input parameters as below,
Now, all set , our flow is ready for the test, click the test button, and select I’ll perform the trigger action and click on Save & Test.
Provide values for start time, end time, and subject in input parameters and click on Run Flow.
Here you can see the success screen as below, and Teams meeting is generated automatically with join URL.
You can send this join URL to your customers and/or co-workers via email, to make their work easier and automated.
Using this connector you can also able to fetch User details, user group info, teams, calendar, Mail, Task, etc. In Graph API’s there are multiple sub APIs you can use those and can achieve your requirements
Using this connector you can also able to fetch User details, user group info, teams, calendar, Mail, Task, etc. In Graph API’s have multiple sub APIs, you can use those and can achieve your requirements easily, without coding.