Configure Webhook Reception in Slack

Prev Next

NOTE: This documentation was written based on Slack documentation at the time of release. Check Slack for the most current documentation.

Send SysTrack sensor notifications to a Slack channel. In Slack, you create an app with an incoming webhook for the channel. In SysTrack, you add the webhook URL as a sensor notification recipient and add the recipient to a sensor notification.

Create a Slack Application

Go to https://api.slack.com/apps/new and create a Slack app.

Enable Incoming Webhooks

  1. Go to the settings page for the Slack app.

  2. Click Incoming Webhooks > Activate Incoming Webhooks. The settings page will refresh to show extra options.

Create an Incoming Webhook

  1. Click Add New Webhook to Workspace.  

  2. Select a channel that the app will post to and click Authorize.

    NOTE: To add the incoming webhook to a private channel, you must be in that channel.

  3. In app settings, Webhook URLs for Your Workspace section there is a new entry with a webhook URL. For example:

    https://hooks.slack.com/services/T00000000/B00000000/
    XXXXXXXXXXXXXXXXXXXXXXXX

This URL is the new incoming webhooks that is specific to a single user and a single channel. Use this URL to create a webhook in SysTrack.

Test the Incoming Webhook

  1. Create an HTTP POST request. For example:

    POST https://hooks.slack.com/services/T00000000/
    B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
    Content-type: application/json
    {
    "text": "Hello, world."
    }					

    NOTE: The URL from Create an Incoming Webhook and this URL must be the same.

  2. To verify, go to the channel where you installed the app. The "Hello, world." message is posted there.

Add the Webhook Recipient in SysTrack

To add a recipient, Configure must be unlocked for editing. See Unlock for Editing.

  1. Go to Configure > Sensor Configuration > Notifications, and select the Recipients tab.

  2. Add a webhook recipient. See Webhook Support for Sensor Notifications. Use these values:

    • URL: the Slack webhook URL from Create an Incoming Webhook.

    • Request Method: POST.

    • Authentication: Specify Authentication via a Header (default), with no header.

    • Body: the template in Webhook Body Template for Slack, below.

  3. Click Add Recipient.

  4. Add the recipient to a sensor notification. See Manage Sensor Notifications.

  5. To check the setup, wait until the sensor notification activates. The message appears in the Slack channel.

Webhook Body Template for Slack

Copy and paste this content into Body in the Add New Recipient dialog box, and edit it as needed. For the variables you can use, see Sensor Notification Webhook Body Templates.

TIP: For Slack, you need the URL you generated, it must use the POST method, and it needs a body like the one shown below.

{
	"blocks": [
		{
			"type": "rich_text",
			"elements": [
				{
					"type": "rich_text_quote",
					"elements": [
						{
							"type": "text",
							"text": "@{notificationName}",
							"style": {
							"bold": true
							}
						}
					]
				}
			]
		},
		{
			"type": "context",
			"elements": [
				{
					"type": "mrkdwn",
					"text": "*Activated* @{activationTime}"
				}
			]
		},
		{
			"type": "rich_text",
			"elements": [
				{
					"type": "rich_text_section",
					"elements": [
						{
							"type": "text",
							"text": "Sensor(s): ",
							"style": {
							"bold": true
							}
						},
						{
							"type": "text",
							"text": "@{sensorNamesUnquoted}"
						}
					]
				},	
				{
					"type": "rich_text_section",
					"elements": [
						{
							"type": "text",
							"text": "Group: ",
							"style": {
								"bold": true
							}
						},
						{
							"type": "text",
							"text": "@{groupName}"
						}
					]
				},
				{
					"type": "rich_text_section",
					"elements": [
						{
							"type": "text",
							"text": "Activation: ",
							"style": {
								"bold": true
						}
					},	
					{
						"type": "text",
						"text": "@{activationThresholdText}"
					}
				]
			}
		]
	},
	{
		"type": "context",
		"elements": [
			{
				"type": "plain_text",
				"text": "@{notificationDescription}"
			}
		]
	},	
	{
		"type": "section",
		"text": {
			"type": "mrkdwn",
			"text": "<@{notificationActivationDetailsURL}|Learn More in SysTrack>"
		}
	}
]
}