Post Message to Microsoft Teams through PowerApps


Posted By : Rakesh Pandey

Added : August 16, 2024

3 Comments


Hope you all liked our recent blog on “Getting started with PowerApps component“,  now we will learn to Post Message to Microsoft Teams through PowerApps. We will discuss in detail how we can post message to a channel created in the group of MS teams.

We all know that MS Teams is getting popular day by day. And at some point we will need to integrate with PowerApps. May be someone already have this requirement in their hand. So let’s start integration of teams with powerapps.

Create a New Data Connection

First we will create a new data connection in our app. Follow below steps.

  • Click View -> Data sources
  • Add data source -> New Connection -> Select Microsoft Teams
Microsoft Teams through PowerApps

After establishing the data connection, we will create our screen with different controls.

Microsoft Teams through PowerApps
We will bind items to drop downs and galleries by below formaula
Dropdown 1 -> Items -> MicrosoftTeams.GetAllTeams().value
Dropdown 2 -> Items -> MicrosoftTeams.GetChannelsForGroup(Dropdown1.SelectedText.id).value.id
Gallery 1-> MicrosoftTeams.GetAllTeams().value
Now we will add two labels in gallery 1. Text value for first label is ThisItem.displayName and second label is ThisItem.id
Gallery 2 -> Items ->MicrosoftTeams.GetChannelsForGroup(Dropdown1.SelectedText.id).value
Add two labels in gallery 2 too, same as of gallery 1. Text value for first label is ThisItem.displayName and second label is ThisItem.id

We are using galleries to show GUID and display name of Group and channels of MS Teams.

Write below formula on the POST button. 
MicrosoftTeams.PostMessageToChannel(Dropdown1.SelectedText.id,Dropdown1_1.SelectedText.id,{body:{content:TextInput1.Text,contentType:0}});Refresh(MicrosoftTeams.GetAllTeams())
For detailed guide on MicrosoftTeams.PostMessageToChannel method please refer this link.

Explanation of function: PostMessageToChannel(groupId, channelld, rootMessage)

groupld: unique id of the Team (string)
channelld: unique id of the channel (string)
rootMessage: message to be posted (record)

The rootMessage body record is made up of these values:
content: message to be posted
contentType: 0 for text or 1 for html

After doing all the above steps you post message to the desired channel of your MS Teams. If you like this post, please share and subscribe our site for more upcoming posts.

5 1 vote
Article Rating
Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Bader
Bader
4 years ago

Thank you so much for this quick and useful post.

Liran.Pingle
Liran.Pingle
3 years ago

this is great
how can i send message to only one person in my organization?

Chandrakala Chilaka
Chandrakala Chilaka
1 year ago

MicrosoftTeams.PostMessageToChannel(“Testing”,Dropdown4.SelectedText.id,{body:{content:TextInput2.Text&“:”&Dropdown3.SelectedText.Value&“:”&Dropdown4.SelectedText.Value,contentType:0}});

I used the group ID instead of the field name, but it’s not working.”

Blog Post Categories

Blog Post Categories

3
0
Would love your thoughts, please comment.x
()
x