PowerApps And MS Teams Integration

Introduction

 
In this article, we will learn about Power Apps and MS Teams Integration. You will see how to post messages to Teams from PowerApps and @ mention people, how to create channels, and a lot of the mechanics so you can integrate this critical data source.
 

Create PowerApps

 
You need to first login to PowerApps using your tenant account and create one blank canvas app using a tablet layout and provide your app name.
 
Then  you need to create a data source connection. Click on the data source icon and search for the Microsoft Teams and create a data source.
 
PowerApps And MS Teams Integration
 
Login into your Microsoft Teams accounts and create Teams and Channels if you don’t have anything created previously. Below are my Teams and Channels which I’ve created for this session.
 
PowerApps And MS Teams Integration
 
Now, switch back to the PowerApps and insert the vertical gallery control on the screen and rename it to "TeamsGallery". We need to set the Items property of gallery control to display the Team list in a gallery control. Then you can select the layout title, subtitle, and body of the gallery control.
 
PowerApps And MS Teams Integration
 
Set the item property of title, subtitle, and body as per the below screenshot.
 
PowerApps And MS Teams Integration
 
In the next step, we need to display the channels under selected Teams. Insert the vertical gallery control and rename it to "ChannelGallery". Set the items property to display the channels based on the selected teams in TeamsGallery. We need to pass the id parameter of the selected items of TeamsGallery to fetch the respective channels of it. Set the same Item property for title, subtitle, and body as TeamsGallery.
 
PowerApps And MS Teams Integration
 
Now, we’re going to display the messages under the channels in a new gallery control. Insert the new vertical gallery control and rename it to "MessageGallery". In Items property we need to pass the id of selected items in TeamsGallery and ChannelGallery control to view the messages in MicrosoftTeams.GetMessagesFromChannel function.
 
PowerApps And MS Teams Integration
 
You can see the output below of Teams, Channels, and Messages of Microsoft Teams in PowerApps. Based on the selected Teams, Channels will be displayed, and based on the selected Channels, Messages will be displayed.
 
PowerApps And MS Teams Integration
 
So far, we just retrieved the data from Microsoft Teams and displayed them in PowerApps. Now, we are going to create Channel, add members, and post messages in Microsoft Teams using PowerApps. Let’s do that.
 
Add button control in PowerApps and rename it with "Create Channel". Once we click on the button, we are going to create one Channel under Teams. There is a function, MicrosoftTeams.CreateChannel, with two parameters, one is group Id which is nothing but the Team Id from the TeamGallery and another is display name which will be the name of the newly-created Channels.
 
Below is the OnSelect property of Create Channel button with the required parameters.
 
PowerApps And MS Teams Integration
 
Once we click on the "Create Channel" button, you can see the new Channel created under my D365 Team with the name "PowerApps Channel".
 
PowerApps And MS Teams Integration
 
Now, we are going to add a new member to Team. Insert the button control on screen and rename it with "Add Member". In MicrosoftTeams.AddMemberToTeam function we need to pass two parameters; one is the ID of Teams where we are going to add the member, and another is the email address of the new member. Below is the OnSelect property of button control.
 
PowerApps And MS Teams Integration
 
Click on the Add Member button and you can see the member is added to the provided team.
 
PowerApps And MS Teams Integration
 
Lastly, we will learn about how to post a message on Channel. Insert the RichTextEditor and Dropdown control and button on the new screen. Add Office 35 Users data source and bind users in the dropdown using this data source. We will tag the selected user from the dropdown list in the message.
 
On the button OnSelect property, we need to pass three parameters in MicrosoftTeams.PostMessageToChannelV3 function.
  1. Group ID – This is the Team Id
  2. Channel ID – This is the Channel id where we are going to post the message
  3. Body – Body is the record, so we need to pass the content and contentType in this
Below is the OnSelect property of the Post Message button.
 
PowerApps And MS Teams Integration
 
Run the PowerApps and provide the input as below.
 
PowerApps And MS Teams Integration
Here is the output based on the provided input in HTML format and mention the user selected from the dropdown in the message.
 
PowerApps And MS Teams Integration
 

Conclusion

 
This way, we can use the Microsoft Teams data source in PowerApps and post a message, mention users, create channels, and many more through PowerApps and a lot of the mechanics so you can integrate this critical data source as per your business requirements. Happy Learning!!