Adding PowerApps as Teams application to Teams via Graph API

Service Desk – Tablet

You may already be aware that you can export a PowerApps to Teams. In case you haven’t heard about this part check this URL: https://powerapps.microsoft.com/en-us/blog/add-your-canvas-apps-to-teams/

However, the real interest is in what we can do with PowerApps once we have uploaded the application to Teams App Catalog.

You need to figure out, before progressing, a few IDs:

UserID you want to test with. Find yourself: https://graph.microsoft.com/v1.0/me/
TeamID you want to test this with: https://graph.microsoft.com/v1.0/me/joinedTeams
Retrieve all channels (ChannelID of the one you choose) of a team: https://graph.microsoft.com/v1.0/teams/{team-id}/channels
All installed applications (once you have added the application to Teams, note you need to grant some permissions for this one ): https://graph.microsoft.com/beta/appCatalogs/teamsApps

Adding PowerApps application to user

Using quite simple Graph API commands you can add application to specific users. Of course you can do this with Application policies as well, but if you think about automated management and provisioning a API is always a API.

Adding PowerApps application to user

Using POST command to /users/{userID}/teamwork/installedApps we can add an application to user’s personal apps (ie: left rail apps). The payload contains the application ID. And. That’s it. The application appears in user’s apps. No, it is not pinned in the left – but soon(ish) there will be a feature that allows user’s to do it manually – or using PowerShell: https://docs.microsoft.com/en-us/powershell/module/skype/set-csteamsappsetuppolicy?view=skype-ps

Service Desk
Service Desk – All tickets

Adding PowerApps to teams as tabs

This has been available manually (add PowerApps tab) for a long time. And I did some testing how to use GRAPH API to add a PowerApps as teams tab earlier – almost a year ago. This version required you to add PowerApps as a tab first manually and then reverse engineer the tab configuration code before applying it to other teams. However with PowerApps as applications it is a lot easier!

First. Open the Teams PowerApps zip file and open the manifest.json file. From there you will need to grab a few things to clipboard and prepare to do a bit of manual editing. The section you need is called ”staticTabs”. From there you need to take the entityID and Name (if you wish). And application ID you had earlier already.

Then you can format your JSON payload content and call https://graph.microsoft.com/v1.0/teams/{TeamID}/channels/{channelID}/tabs

{
   "displayName": "PowerApps as App tab",
   "teamsApp@odata.bind" : "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{applicationID}",
   "configuration": {
   	"entityId": "/providers/Microsoft.PowerApps/apps/{PowerAppsID}",
        "contentUrl": "https://apps.powerapps.com/play/providers/Microsoft.PowerApps/apps/{PowerAppsID}?source=teamstab&locale={locale}",
        "websiteUrl": "https://apps.powerapps.com/play/providers/Microsoft.PowerApps/apps/{PowerAppsID}?source=teamsopenwebsite"
        } 
}
Team ID

And looking at the team we can see the tab appearing.

In progress

Now, that can be repeated to every new team in provisioning, for example. And if there are changes you can just update the Teams application with a new version number and it will be be updated in every team. So yes, this is a lot easier than it used to be a year ago.

After this, it would be just the matter of adding the desired applications to management & provisioning processes.

As usual, Docs.Microsoft.Com provides a great resource for Graph API calls and some examples. https://docs.microsoft.com/en-us/graph/api/user-add-teamsappinstallation?view=graph-rest-beta&tabs=http

About the Author:

Principal Consultant and Benefit Miner in Office 365 and Modern Work Helping and coaching customers to find benefits and value when adopting new tools, methods, ways or working and practices into daily work-life equation. I am always eager to challenge current situation and dig out new possibilities and ways to think and work. I work with a excellent group of professionals and our team could be called Benefit Miners since that’s our goal: discover best benefits so our customers get best value and ROI out of chosen tools. Buzzwords and tags that describe what I do: #Office365, #MicrosoftTeams, #SharePoint, #ModernWork, #Adoption, #Benefits #Value #ROI #Digital Transformation, #Roadmaps, #BusinessDesign #Digitalization #TeamsTorstai

Reference:

Nopanen, V. (2019). Adding PowerApps as Teams application to Teams via Graph API. Available at: https://myteamsday.com/2020/01/20/add-powerapps-application-tabs-graph-api/ [Accessed: 11th February 2020].

Check out more great Microsoft Teams content here or join our mailing list to stay up to date.

Share this on...

Rate this Post:

Share: