How-to: Integrate MS Teams#

Integrate Microsoft Teams with HCL Launch to post notifications automatically to your Teams channel whenever a specific deployment event happens.

By using the Incoming Webhook connector in Teams, you can integrate HCL Launch services so that you get notified of an event through the Teams channels.

In this example, you'll learn about the requirements and procedures to integrate Teams with HCL Launch. To integrating Teams with HCL Launch, follow these steps:

Parent topic: How-tos

Step 1: Obtain the webhook URL from your Teams channel#

  1. Open the Teams channel where you want to add the webhook and select (•••) More Options from the top navigation bar.

  2. Choose Connectors from the menu and search for Incoming Webhook.

  3. Select Configure, provide a name, and, optionally, upload an image avatar for your webhook.

  4. Submit the details.

    The dialog box presents a unique URL that will map to the channel. Make sure that you copy and save the URL. You have to provide this URL when you add the webhook to a process.

    The webhook URL looks similar to the following example:

    https://hclo365.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000@00000000-0000-0000-0000-000000000000/IncomingWebhook/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/00000000-0000-0000-0000-000000000000

  5. Select Done.

The webhook is added to the Teams channel and posts a confirmation message like this example:An example of Teams incoming webhook addition

Note: For additional information about Teams webhooks, refer to the MS Teams documentation.

Step 2: Format the message card#

A message card is defined in a JSON format that includes the message in text, links, and image, if required. For HCL Launch, you can create a message card that refers to the process name, status, and a link to the process deployment page. The message card format is used as body in the webhook template.

The following code is provided to create an example message card:

## PROPERTY Content-Type: application/json
#set( $themeColor = $fn.getStatusColor( $request.Result ) )
#if ( $themeColor.contains("#FFFFFF") )
  #set ( $themeColor = "#0072C6" )
#end
#set( $text = "" )
#set( $text = "${text} <h2>HCL Launch Process $process.Name $fn.getStatusDisplayName($request.Result)</h2>" )
#set( $text = "${text} <table> " )
#set( $text = "${text}   <tr><td>Process:</td><td>$process.Name</td></tr>" )
#if ($resourceName)
  #set( $text = " ${text} <tr><td>Resource:</td><td>$resourceName</td></tr>" )
#end
#set( $text = "${text}   <tr><td>Requested by:</td><td>$user.Name</td></tr>" )
#set( $text = "${text}   <tr><td>Requested on:</td><td>$scheduledDate</td></tr>" )
#set( $text = "${text} </table>" )
#set( $text = "${text} <br>Click <strong>View Details</strong> for more information" )
{
    "@context": "https://schema.org/extensions",
    "@type": "MessageCard",
    "themeColor": "$themeColor",
    "title": "HCL Launch Process $fn.escapeJson($process.Name) $fn.getStatusDisplayName($request.Result)",
    "text": "$fn.escapeJson($text).trim()",
    "potentialAction": [
        {
            "@type": "OpenUri",
            "name": "View Details",
            "targets": [
                {
                    "os": "default",
                    "uri": "$fn.escapeJson($externalUrl)#$requestType/$processId"
                }
            ]
        }
    ]
}

Note: The preceding template posts notifications for all event types. You can customize the above available message card as per your team requirement. See MS Teams documentation for more information.

Step 3: Create a webhook template#

Create a webhook template for an event so that when the event happens a notification is triggered on Teams.

  1. Select Settings > Webhook Templates > Create Webhook Template.

  2. Provide a name and description for the template. For this example, give the name as Process failure notification.

  3. Click on Body area and paste the example code from the step 2.

  4. Choose the event type Process Failure from the Type field.

  5. Submit your changes.

The webhook template is created and ready to be added to an application.

Step 4: Add webhook template to an application#

You can add a webhook template to applications, generic processes, and external approval processes. For this example, you add the template to an application.

Make sure that you created an environment for the application and have resources added to it.

  1. Select Applications > application name > Configuration > Webhooks > Add Webhook.

    The Add Webhook window is displayed.

  2. Copy the URL generated that was generated in step 1 and paste it in the URL field.

  3. Specify the event type as Process Failure.

  4. Select the template name that you created in step 3 from the Webhook Template field.

  5. Specify the environment name from the Environments field.

  6. Submit your changes.

The webhook template is added to the application. When an application process run on the environment and fails, the Teams channel shows the following notification.

|Launch-Webhook-Integration-Test 6/13 6:53 PM| |An approval failed for the App application on the Env environment| |An application process was rejected during its approval process| |Application: App Environment: Env Requested by: admin Scheduled for: Sun Jun 13 18:52:31 IST 2021 Description: ${request.Description}| |Click View Details for more information.|