How to integrate Microsoft Teams with Applications Manager using Webhook?

How to integrate Microsoft Teams with Applications Manager using Webhook?

Microsoft Teams is a personal/workplace communication and collaboration platform that helps you stay connected over chat, calls, and video meetings. Using Webhook, you can now integrate Microsoft Teams with Applications Manager and receive real-time alerts on network faults right in your team channel.

Integrate using MS Teams Graph API

Step 1: Configuring MS Teams
  1. Go to Microsoft Azure home page.
  2. In Azure services, go to App registrations,
    oauth
  3. Click New registration,
    oauth

  4. Follow the below steps to register an application

    4.1. Enter the name of the application(Applications Manager).
    4.2. Choose the account type. The Accounts could be in any organizational directory (Azure AD directory or Multi-tenant) or personal Microsoft accounts (e.g. Skype, Xbox). You may choose to opt different account type based on your requirement
    4.3. For Redirect URL, choose type as Web and paste the Redirect URI value from Settings -> Credential Settings -> OAuth Provider -> Add OAuth provider pop-up in Applications Manager GUI
    4.4Then click Register, to create an application.

  5. After registering the application, you will be redirected to the Application home page. Copy the Application ID, it will be the Client ID.


  6. Click "Add a certificate or secret" to get the Client Secret. Then follow the below steps,


  7. Click "New client secret".
  8. Provide the Description & Expires time for the client secret, and click Add.
  9. Copy the Value, this will be the Client Secret. (Save this value for future use, as it will become unreadable after some time.)

    9.1. If the value goes unreadable, and you are in need of client secret, you can create a new client secret and use the value.
    9.2. This client secret will expire depending on the duration you provide. Once it has expired create a new client secret and use the value.

  10. For Authentication URL and Token URL, go to the Application home page (Overview) and click Endpoints, there copy "OAuth 2.0 authorization endpoint (v2)" as Authentication URL and "OAuth 2.0 token endpoint (v2)" as Token URL.
Step 2: Configuring OAuth in Applications Manager
  1. Go to Settings -> Credential Settings -> OAuth Provider -> Add OAuth provider and provide the following details

    1.1. Provider Name - A unique display name for each OAuth configuration.
    1.2. Leave the Grant Type drop down to the default value which is Authorization Code
    1.3. Fill the Client ID and Client Secret value generated during the steps 5 and 9 respectively. 
    1.4. Provide the Authorization endpoint URL copied from step 10.
    1.5. Add the below scope values
           Group.ReadWrite.All
           ChannelMessage.Send
           offline_access
    1.6. Provide the Token endpoint URL copied from step 10.
    1.7. Choose Post request body for Token Request Method
    Note: offline_access scope is required to get Refresh token from Microsoft.

  2. Click Authorize, you will be taken to Microsoft sign in page. Provide the credentials and Sign in. Then a page similar to below will appear.


  3. Enable the checkbox and click Accept to provide consent for accessing the application. Once Accept button is clicked, OAuth provider is added successfully in Applications Manager.

Step 3: Configuring Webhook / Rest API Action in Applications Manager
  1. In the Applications Manager GUI, Go to Actions -> Webhook / Rest API Action


  2. Provide the below mentioned data to configure Webhook / Rest API Action

    2.1. Provide a display name for the action
    2.2. Provide the MS teams Graph API URL that is used to send alert messages from Applications Manager to a chat/channel in MS Teams.
    For example, if you need Applications Manager to send alert messages to a particular channel in MS teams. The API URL will look like below
     -> HTTP POST /teams/{team-id}/channels/{channel-id}/messages. Refer to this Microsoft teams Graph API document to know more about available APIs.
     -> team-id can be taken by clicking on the (...) three dots present on the right side of the team name. From the flyout menu as displayed in the image below click on Get link to team


    -> A popup with the link would appear and in this link, teams Id is the value of groupId


    -> channel-id can be taken by clicking on the (...) three dots present on the right side of the channel name. From the flyout menu as displayed in the image below, click on Get link to channel.


    -> A popup with the link would appear, the value mentioned after the path /channel is the channel id as mentioned in the image below


    -> After replacing actual team-id and channel-id, final API URL will look like below
    https://graph.microsoft.com/v1.0/teams/825a31ca-7e8e-4576-9482-87ce52bdb727/channels/19%3Ae1acc65f78de4476b651a7de5b26b7a9%40thread.skype/messages
    -> Use this value in HTTP(s) URL field.
  3. Choose POST as Form Submission Method
  4. Choose JSON as PayLoad Type
  5. In the Custom Parameters textbox, add the following content (you can modify the JSON as per your wish) - 
    {
      "body": {
                     "contentType": "html",
                     "content": "Monitor Name : $MONITORNAME <br> Attribute Name : $ATTRIBUTE <br> Severity : $SEVERITY <br> Host Name : $HOSTNAME <br> Message : $RCAMESSAGE"
                   }
    }
  6. Select OAuth in Authentication Method drop-down
  7. Select the OAuth profile that is added for MS Teams integration in OAuth Providers drop-down
  8. Click the Create Action button

Integrate using MS Teams connector

Step 1: Configuring MS Teams
  • Open the required Microsoft Teams channel to which Applications Manager alert has to be communicated.
  • Click on More () option next to the channel name and choose Connectors.
  • Select Incoming Webhook from the list of displayed options. 
  • In the new window, provide a name for the webhook and click on Create.
  • Copy the webhook URL generated by MS Teams.
Step 2: Configuring Applications Manager
  • In Applications Manager web client, go to Actions > Webhook / REST API action.
  • Enter the display name of the action.
  • Paste the webhook URL generated by Microsoft Teams in the HTTP(s) URL field.
  • Choose the Form Submission Method as POST. 
  • Choose the PayLoad Type as JSON.
  • In the Custom Parameters textbox, add the following content:
    {
    "text":"Monitor Name : $MONITORNAME <br> Attribute Name : $ATTRIBUTE <br> Severity : $SEVERITY <br> Host Name : $HOSTNAME <br> Message : $RCAMESSAGE"
    }
  • Under Request Headers, specify the Header Name as Content-Type and Header Value as application/json.
  • Enter the remaining fields such as User Agent, Authentication Method, etc., if required.
  • Select the email ID in Notify after action execution for both success and failure conditions to receive notifications, if required.
  • Finally, enter the Timeout value and click on Create Action.

                    New to ADSelfService Plus?