Teams actions

Have you ever tried adding new tabs in your teams in Microsoft Teams? When you do this with Power Automate you might need to have a look at Microsoft Graph.

The out of the box Teams actions in Power Automate

I had a look through the actions in the Microsoft Teams connector but there isn’t anything there that could be of any help when you try to create new tabs in your team.

In my case I need to add a Power App to the default tabs of my project team that is being created. I want to do this in an automated way. so why not use Power Automate.

I found a useful starting point in the Teams Rocks site that pointed me towards Microsoft Graph after I attempted Microsoft Teams PowerShell.

The MS Graph calls needed

The first thing to look at is the call that will create a new tab. The endpoint that needs to be called with a POST is the following one:

https://graph.microsoft.com/beta/teams/{id}/channels/{id}/tabs

So we will need to get the id of the Team and the id of the channel. We could now of course use MS Graph to collect these but why not just use the actions available in Power Automate to do this for me.

With the Get a team and List channels actions I can get all the information that I need to build up my end point uri.

Authentication

Similar to my post about Updating Excel templates using Microsoft Graph I will use an app registration to handle the permissions to Microsoft Graph.

So far from all the posts mentioned we should have a flow that looks like this.

Create new tabs in your Teams in Microsoft Teams using Power Automate Microsoft Office 365 image 38

Nothing new there.

Time to make that call to the endpoint that was mentioned earlier to add my tab to my team.

Next to calling the end point I will also need to send body. The body will need to look like this. Note that the teamsApp@odata.bind is making this into a website type app.

{
  "displayName":"My Power App",    "teamsApp@odata.bind":"https://graph.microsoft.com/beta/appCatalogs/teamsApps/com.microsoft.teamspace.tab.web",
 "teamsAppId":"com.microsoft.teamspace.tab.web",
 "configuration":  {"entityId":"2DCA2E6C7A10415CAF6B8AB6661B3154",
                    "contentUrl":"https://apps.powerapps.com/play/f08b61bb-c8bf-4210-aa54-4ecbdd33a5a2?tenantId=1985c6a6-11d8-4c13-84a9-1847f555ae47",
                    "websiteUrl":"https://apps.powerapps.com/play/f08b61bb-c8bf-4210-aa54-4ecbdd33a5a2?tenantId=1985c6a6-11d8-4c13-84a9-1847f555ae47",
                    "removeUrl":""
                   }
}

Now we can translate this into Power Automate flow language. So far the bits that we have got will look like this:

Create new tabs in your Teams in Microsoft Teams using Power Automate Microsoft Office 365 image 39

But we will need to do some more still. The first thing will be to add the access token to the call. Othewwise you will get errors like :

Access token is empty.

Just add the following to the HTTP request, where the access token is retrieved from the compose action following the first HTTP request.

Create new tabs in your Teams in Microsoft Teams using Power Automate Microsoft Office 365 image 40

If you now run it you might get an UnknownError. I hate it when APIs give me Unknown errors. Unless you know what you are doing it will be difficult to find the next step.

In this case I know that I haven’t set the permissions in my app registration yet. So that will be the first thing to do.

Set the app registration permissions

Within the app registration in Azure you will have to supply the following application permissions (not delegated permissions!).

Create new tabs in your Teams in Microsoft Teams using Power Automate Microsoft Office 365 image 41

Now when you run your flow you will find a successful flow that has created the tab with a power app.

Create new tabs in your Teams in Microsoft Teams using Power Automate Microsoft Office 365 image 42

The end result, a new tab created in Teams

Then when you look in Microsoft Teams you will find new tabs added to your team!

new tabs added to a team in Microsoft teams using Power Automate
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

2 thoughts on “Create new tabs in your Teams in Microsoft Teams using Power Automate”

Leave a Reply

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

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading