Integrate with Microsoft Teams
- 07 Dec 2023
- 2 Minutes to read
- Print
- DarkLight
Integrate with Microsoft Teams
- Updated on 07 Dec 2023
- 2 Minutes to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
Microsoft Teams provides its users a collaborative online platform to chat by text, have a video chat, share documents, and other tools. Using Microsoft Teams with Microsoft's Azure Cloud system, users can integrate with a Microsoft Teams app or channel within a Flow that is configured as a REST integration.
Prerequisites
- Microsoft Teams Account and channel
- Registered application in Azure
Example
Configuring Microsoft Teams as an OAuth Provider and Creating a Token
- Following Establishing an OAuth Provider, enter "https://login.microsoftonline.com/common/oauth2/v2.0/token" for the Token Request URL and "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" for Authorize URL.
- Provide the Default Consumer Key, Callback URL, and the Default Consumer Secret Key. Click SAVE.
Field Name Value Callback URL Redirect URI for the application Default Consumer Key The Application Client ID (under the Overview page for the application in Azure) Default Secret Key Secret Key (under the Certificates & Secrets page of the application in Azure) - Following Creating OAuth Tokens, under OAuth Flow, select Authorization Code. Provide the Scope for the Token by entering "https://graph.microsoft.com/User.Read https://graph.microsoft.com/Group.Read.All https://graph.microsoft.com/Group.ReadWrite.All https://graph.microsoft.com/ChannelMessage.Send offline_access".
- Click RequestToken and click OK.
Setting up REST Integration
- Following REST Service Integration Overview, under Service URL, enter "https://graph.microsoft.com/v1.0". Under the AUTHENTICATION category, select Use OAuth. Select the Use Custom Tag in Auth Header option. In the Custom Tag for Auth Header box, enter "Bearer" and click SAVE INTEGRATION.
- From the newly created REST Service's Folder, select All > Add Method to Service. From the New REST Service Method window, under URL (Relative to Base), enter "/teams/{teamid}/channels/{channelid}/messages".
- Under the HTTP Method field, select POST. Under the Content Type field, select JSON. Under the Request Body Format field, select Get String From Flow. For Step Output Type, select Raw Value. Click OK.Note on URLThe Team and Channel ID's represent the unique value belonging to the integrated channel.
To obtain the Team ID, navigate to Microsoft Teams, click the ellipses beside the Team Name and select Get link to team. Copy the Group ID from the URL.
To get the Channel ID, select the ellipses beside the Channel Name and click the Get link to channel. Copy the text between "channel/" and "/{CHANNELNAME}" from the URL.
Using Integration Steps
- In a Designer Project, create a new Flow.
- Attach a Custom Merge [NVelocity] step to the Start step by navigating to DATA > TEXT in the Toolbox panel. On the Properties panel of the Custom Merge step, enter in the below JSON text into the Template field. Enter "This is a test message." in the Message field.
{ "body": { "content": "$Message" } }
- In the Toolbox, navigate to INTEGRATION > REST SERVICES > [REST SERVICE NAME], and attach the REST Service method step to the Custom Merge step. From the Properties panel, , set the OAuth Token field to Constant and select the respective Token from the dropdown. Then, Select From Flow map MergedString to Request Body.
- Connect both the Done and Error paths to the End step. Click Save to save the Flow.
Debug
- On the top action bar, click Debug.
- Click START DEBUGGING.
- After the Flow runs, verify that the message was sent by navigating to the Channel in Microsoft Teams and checking the Posts tab.
For further information on Integrations, visit the Decisions Forum.
Was this article helpful?