Integrate with Microsoft Teams
  • 07 Aug 2024
  • 2 Minutes to read
  • Dark
    Light

Integrate with Microsoft Teams

  • Dark
    Light

Article summary

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

Example

Configuring Microsoft Teams as an OAuth Provider and Creating a Token 

  1. 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
  2. Provide the Default Consumer Key, Callback URL, and the Default Consumer Secret Key. Click SAVE. 
    Field NameValue 
    Callback URLRedirect URI for the application
    Default Consumer KeyThe Application Client ID (under the Overview page for the application in Azure)
    Default Secret KeySecret Key (under the Certificates & Secrets page of the application in Azure)

  3. 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". 
  4. Click RequestToken and click OK.

Setting up REST Integration

  1. 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. 
  2. 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".
  3. 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 URL 
    The 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

  1. In a Designer Project, create a new Flow.  
  2. 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"
       }
    }

  3. 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.
  4. Connect both the Done and Error paths to the End step. Click Save to save the Flow.


Debug

  1. On the top action bar, click Debug. 
  2. Click START DEBUGGING. 
  3. 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?