Integrating Power Apps and Microsoft Teams using Custom Connectors and the Graph API

Microsoft Graph is a RESTful web API that enables you to access Microsoft Cloud service resources and a custom connector is a proxy or a wrapper around an API that allows the underlying service to talk to Microsoft Power Automate, Microsoft Power Apps, and Azure Logic Apps.

With that in mind, we are able to create incredible flexible solutions leveraging Microsoft Flows and that’s what we’ll do on this post.

So, pretty straightforward requirement:

As a project manager, I want to be able to create a team with a set of channels in Microsoft Teams from a given project.

The solution that I came up with was to create a flow that is triggered within a project record in my Model Driven App that uses a Custom Connector to connect with the Graph API.

To achieve that the first thing we need to do is to set up an Instant Flow and select the “When a record is selected” option, that will allow you the choose the entity that will show the flow whenever a record is selected.

After that we create the flow it self, let’s go through each step:

When a record is selected : Step to choose the entity that will let the user run the flow when a record is selected

Initialize variable : Here we initialize the variable teamCreated it might look like a workaround especially when you see the “Do until” step with a Delay on it but in my defense, it’s Microsoft recommendation to wait for 10 seconds after a Group is created to create a Team and try 3 times, if you don’t believe me please check it here.

Create Group : Here we call our custom connector to perform the task that we want, in this case create a Group so we can create a team for it. (If you are not familiarized with custom connectors have a look at here.)

Do until : As I mentioned before, this step exist to make sure the group is there before we move on and create the team.

Delay : 10 seconds delay between each attempt

Set Variable : When success we set the teamCreated value to true

Channel – Fun Stuff : Finally after the group and team was created we can create a channel within our team.

With all in place you should see a new flow in the entity that you selected on the first step to execute it and hopefully bring you the results you expect.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *