Slack (www.slack.com) is a popular chat/communications platform used by thousands of organizations around the world.
Slack provides an API to allow third-party apps such as Omnilert to post messages to slack channels. Here's how to set up such a connection to post Omnilert alerts to Slack as using Webhooks.
(Please Note: You will need administrator access to Omnilert and your organization's Slack account to complete this setup.)
Step 1: Create a Slack application and enable Slack's "Webhooks" feature.
You will need to create a Slack "app" to receive the alerts sent by Omnilert. This app will need to have its "Webhook" feature enabled on Slack. (Your local slack admin may need to assist you in this step.)
See https://api.slack.com/messaging/webhooks for detailed instructions from Slack on how to create an app and enable webhooks for that app.
The end result of that setup will be a URL provided by Slack. Copy that URL. You will need it for Step 3.
Step 2: Create a new Webhook Endpoint in Omnilert
In Omnilert, you will need to set up a new "Webhook" endpoint to send messages to your Slack app.
Go to Endpoints > Add Endpoint to create a new Webhook endpoint in Omnilert's admin portal. See: Adding a new Endpoint for instructions. (Tip: Be sure to set your new endpoint as "Active")
Step 3: Configure Omnilert Webhook to send to Slack
Next, we need to edit the new webhook endpoint and insert a JSON script to instruct Omnilert with where to send its hook and how to format the hook for Slack to read it.
- Go to Endpoints > Active (or Inactive if you hadn't activated your new endpoint yet!)
- Click on the new webhooks endpoint in the list
- Go to the "Configure" tab for your new webhook endpoint.
- Paste your customized JSON script (see below for code!)
- Check the box to "Bypass Service Status Checks". (Slack's API will not accept "OPTION" requests, so this feature must be disabled for the webhook to work properly.)
- Click Update configuration to save your changes.
The Omnilert configuration JSON script for sending to Slack is quite simple. You'll only need to set 4 parameters in your JSON:
- url = This will be your Slack app's webhook URL from Step 1.
- postData = The payload to send to Slack. Slack will want it to be a parameter called "text" with the text content to display. In the example below, we'll insert the Omnilert content using variables {{webhook_subject}} and {{webhook_body}}
- method = POST (We want to post the data!)
- headers = Where we sent the content type for the posts. This will always be the same thing; "application/json" for Slack.
Example Configuration JSON for sending to Slack:
You will need to customize the code below to meet your needs. At a minimum, you must replace "YOUR_SLACK_WEBHOOK_URL" with the Slack webhook URL created in Step 1 of this guide.
{
"url": "YOUR_SLACK_WEBHOOK_URL",
"postData": {
"text": "*Subject:* {{webhook_subject}} \n *Message:* {{webhook_body}} \n\n `This message sent via OMNILERT`"
},
"method": "POST",
"headers": {
"Content-type": "application/json"
}
}
In this example, we've configured the Slack message to include both the "Subject" {{webhook_subject}} and "Message body" {{webhook_body}} of the Omnilert alert.
Naturally, you can edit the formatting and layout to your own liking. Simply edit the "postData" section of the JSON script accordingly.
(For more info on formatting content in Slack messages, see https://api.slack.com/messaging/webhooks )
Sending Omnilert messages to Slack
After your configuration is complete, you'll be able to send Omnilert messages to your Slack channel right away.
Simply select your new webhook endpoint as your would any other endpoint in Omnilert!
The message will then be posted to Slack via the app created in Step 1.
Comments
0 comments
Please sign in to leave a comment.