Integration between Power Apps and MS Teams allows creating context-aware applications, that access information stored for example in the SharePoint site connected to the team.
Embedding vs integrating
Embedding Power Apps canvas apps is different from creating Canvas Apps in MS Teams.
A Canvas App created in Teams can only be edited using Power Apps app in MS teams.
The environment is not displayed in https://make.powerapps.com/, but can be found using https://make.powerautomate.com/. This is useful when you need to export solution.👈 Still, you won't be able to edit this app via browser.
The app has access to a Teams integration object, which provides context information, for example team id and group id, and channel id.
Embedded Canvas App, on the other hand, is a standalone Canvas App, added to MS Teams.
Embedding Canvas Apps in MS Teams, available since March 2020, gives an app access to the team's context information using the Param('parameterName')
.
The team Id parameter
Sadly... the id returned by teamId
parameter is not a team's guid
, but an internalId
.
The best explanation of these internalIds
can be found in stackoverflow
I find it very unfortunate.
The internal id cannot be used with either the Teams Power Automate actions, or the MS Graph API.
Calling the https://graph.microsoft.com/v1.0/teams?$select=id,internalId
returns null
for the internalId
. The only way of retrieving the guid
is indeed retrieving all the teams the user has access to, and for each of them, retrieving the id
and internalId
values.
In terms of solution design, this seems like an anti pattern...
Moreover, the licensing document states that the M365 licenses provide "limited usage rights" to Power Platform, allowing users to extend the M365 services in order to support business processes. But finding the team's guid requires using Premium connector because the Send a Microsoft Graph HTTP request
action does not support https://graph.microsoft.com/v1.0/teams?$select= id,internalId
query.
So dissapointing...
Fetching id
, driveId
, webUrl
, etc.
Nevertheless... I decided to build a flow that retrieves all the guids, ids, names and paths that might be useful in building Power Platform solutions.
Depending on which Power Automate action you are using, you will need to know the target location's URL
, guid
, driveId
or list title
. I briefly described this topic in my previous post: Data Source Environment Variables in Power Automate actions.
Retrieving these values based on the team and channel internalId
requires the following steps:
- get
guid
s of all teams the user has access to and for each of them, fetch theinternalId
property. If theinternalId
is equal toteamId
provided by the MS Teams context, this is the team you are looking for. theguid
will be used to access team information with MS Graph. Unfortunately, theinternalId
isnull
when retrieving all teams withhttps://graph.microsoft.com/v1.0/teams?$select=id,internalId
get SharePoint folder information for the Teams channel, using the
guid
retrieved in the previous step, and thechannelId
from team's context. Thehttps://graph.microsoft.com/v1.0/teams/{teamGuid}/channels/{channelId}/filesFolder?$select=id,name,parentReference
query returnsid
,name
andparentReference
properties, which are used bydrives
API in the next step.
get SharePoint folder information by calling
https://graph.microsoft.com/v1.0/drives/{driveId}/items/{id}/listItem?$select=id,webUrl,parentReference
. This query returnsfolder id
(integer),absolute URL
and a reference to a SharePoint site used by the channel. TheparentReference/siteId
returnstenantName,SiteId,WebId
.
get library information using
https://graph.microsoft.com/v1.0/drives/{driveId}/list?$select=id,webUrl,name,displayName,parentReference
. This query returns library information:display name
,internal name
which is used as part of the url,library guid
andabsolute URL
get site information using
https://graph.microsoft.com/v1.0/sites/{siteId}?$select=name,weburl,displayName
Results
The output may be used in a parent Power Automate flow, to access library and folder used to store channel's documents.
To test it, add the Get Teams Channel Library Info - test Power App to a MS Teams channel.
The top section displays Teams context parameters. The Fetch folder information button triggers the Get Teams Channel Library Info flow, with results displayed below:
Prerequisites
This Power Automate Flow is using HTTP with Microsoft Entra ID connector, which requires Premium license.
In order to successfully execute the flow, you need to grant the PowerPlatform-webcontentsv2-Connector service principal the following API permissions to Microsoft Graph
resource:
-
Channel.ReadBasic.All
Team.ReadBasic.All
Files.Read.All
Follow the Authorize the connector to act on behalf of a signed-in user procedure to grant the permissions.
Doesn't work!
If you see a " Missing scope permissions on the request." error, it is possible that you tested the flow before granting the required API permissions. Now you have to wait. According to my experience - approximately one hour.
Download the solution
You may download the workflow from the Power-Automate-Get-Teams-Channel-Library-Info github repository.
The flow accepts two parameters: teamsId
and channelId
. Depending on the app type, use the following parameters:
Embeded Canvas App | Integrated Canvas App | |
---|---|---|
teamId |
Param("teamId") |
Teams.ThisTeam.Id |
channelId |
Param("channelId") |
Teams.ThisChannel.Id |
Resources
- Overview of Teams and SharePoint integration
- What is the difference between HTTP with Microsoft Entra ID and HTTP with Microsoft Entra ID (preauthorized) connectors?
- Using an API in Power Automate with Entra ID authentication
- Is there any Microsoft API to get the group Id from channel id? - Stack Overflow
Top comments (0)