Using the standard Power Automate actions for Microsoft Teams we can only create a standard channel, but by using Microsoft Graph with the new ‘Send a Microsoft Graph HTTP request’ action it’s possible to extend the standard actions similarly to my previous post, and create private channels in Microsoft Teams.
Microsoft Graph request format
To create a Microsoft Teams channel via Graph, you need to send a request body representing the channel object.
This object has a property named membershipType, which represents the type of the channel. This property can be set during creation only.
When creating a private channel as urgent, we need to set the membershipType of the channel as private.
Then we run a POST request against the team channels endpoint to create the channel, sending the request body using this format.
Creating a private channel
To create a private channel we can run a POST request against the following graph endpoint:
https://graph.microsoft.com/v1.0/teams/{team-id}/channels
Sample body request (note that the ‘members’ array below contains one owner and a member, a member simply does not have the “owner” role in the roles array):
{
"@odata.type": "#Microsoft.Graph.channel",
"membershipType": "private",
"displayName": "My Display Name",
"description": "A private channel",
"members": [
{
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"user@odata.bind": "https://graph.microsoft.com/v1.0/users('<GUID OF OWNER>')",
"roles": [
"owner"
]
},
{
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"roles": [],
"user@odata.bind": "https://graph.microsoft.com/v1.0/users('<GUID OF MEMBER>')"
}
]
}
Notes:
Sample usage in Power Automate
Below we create a private channel, and before creating it we dynamically get the owner and member using the Office 365 users connector actions:
Results
After running a flow with the action as above, you will get the channel properly created:
Limitations
Currently using this ‘Send a Graph HTTP request’ action it’s not possible to add members to existing channels:
Resources
Channel resource type – Microsoft Learn
Create channel – Microsoft Learn
The post How to create Microsoft Teams private channels using Power Automate and the ‘Send a Microsoft Graph HTTP request’ action appeared first on michelcarlo.