When Microsoft Teams is getting used more and more widely in the company, there usually arises some needs to make some company applications to be easily accessible in many of those teams. The very typical application could be a one or more PowerApps that have been created to make the life easier.
Microsoft Flow provides a easy way to go through Teams and do actions to those teams. However, you do need to get your access tokens (tenant id, application id and application id) from Azure AD. Remember that you are giving permissions to a application – so don’t allow every possible permission – just the ones you need. Refer to this Docs article about Access Tokens https://docs.microsoft.com/en-us/graph/auth-overview
I did the Flow in a demo environment and I did not want to add a PowerApps to every possible team I had there. Looping through Teams in a Flow and selecting just one is NOT efficient but it is easy in Flow. Consider how many times you are going to be running this. Or just take the part about adding your app to a team and apply it to all new teams you provision.
When using HTTP Connector in a Flow the user creating this Flow needs a Flow or PowerApps plan 1 license. The license that comes with Office 365 is not enough. But due to the nature of this flow, this is best left for Admin/Governance users.
Using Teams connector makes getting Teams and Team channels very easy, thus enabling these Superpowers to many more users than just those with more developer-oriented mind.
In some organizations they use a “superuser” account that is added to all project or organizational teams automatically during provisioning (or later). In those scenarios it is easy to loop through all this user’s teams.
What is done in here
- Initialize Variables (like application secret)
- List Teams (Teams Connector). Note: only gets user’s teams, not ALL of them!
- Apply to Each team
- (check if the team name matched the team you want to add this onto)
- List Channels (Teams Connector)
- Only apply to General Channel
- Create HTTP Connector Post URI to add PowerApps application to the team
- If failed – continue
- Create HTTP Connector Post URI to add Company PowerApps to the General tab of the team
Note: I only added slashes (/) to Flow action names for taking screenshots. In reality Flow does not like / in names 🙂
Graph API to add a application (or bot) to a team is
The JSON command is simple and hard-coded here. These codes match for PowerApps
Note Authentication + Tenant, Client ID and Secret in the HTTP Connector.
Adding a application to a team follows Graph API call syntax:
The actual JSON body contains your PowerApps application information.
The easiest way to get the PowerApps application adding code is to add the PowerApps to specific team and channel and use Graph Explorer ( https://developer.microsoft.com/graph/graph-explorer/ to get the application details.
To return all applications in a single tab use GET instead of POST
Result and how to improve
The result is the nicely added company PowerApps in our team.
What could be done to improve this?
- check for adding a tab error and resolve it
- Adding application to only certain kind of teams (like project teams)
- Adding a specific PowerApp application for certain kind of teams