Send notifications to Slack
You can configure Moogsoft Cloud to send alert or incident notifications to Slack using the Slack API. Follow these steps to complete the configuration process.
Before you begin
Before you set up your Slack outbound integration:
Make sure you are signed in with your Slack account on api.slack.com.
Make sure you are signed into your workplace in Slack.
Set up a Slack notification channel
Go to api.slack.com.
Click Create an app > From scratch.
Provide a name for the app and select a workspace. Then click Create App.
Enable incoming webhooks:
Navigate to Features > Incoming Webhooks.
Click the slider to enable the feature.
Configure OAuth and permissions:
Navigate to Features > OAuth & Permissions.
Under Scopes > Bot Token Scopes, add a new OAuth Scope named
chat:write
. This will enable the bot to write messages to the Slack channel.Under OAuth Tokens for Your Workplace, click Request to Install.
Fill out a request message and submit the request.
Once your administrators approve the installation request, open Slack.
Within Slack, create a new channel.
Navigate back to api.slack.com.
Navigate to Features > OAuth & Permissions > OAuth Tokens for Your Workplace and click Install to Workplace. A page will appear requesting permission to access your workplace.
Select the new Slack channel you created and click Allow.
Open Slack. Within Slack, right click your new channel and select Open channel details from the dropdown menu.
Navigate to Integrations > Apps and click Add an App.
Type the name of the app into the search bar and add it to the channel.
Set up outbound webhook in Moogsoft Cloud
Within Moogsoft Cloud, navigate to Integrations > Outbound Integrations > Webhook.
Click Add a Webhook and complete each section according to the following:
Name and Scope:
Provide a unique name and select the type of data that should be sent to Slack (incidents or alerts).
Within the filter section, add conditions to control which incidents or updates are forwarded to Slack.
CREATE Operation and HTTP Configuration:
Set the request method as POST.
Copy and paste the following URL:
https://slack.com/api/chat.postMessage
Under Authorization, select "Bearer Token" from the dropdown menu.
Click Add New Credentials and provide a name.
Go to api.slack.com and navigate to Features > OAuth & Permissions > OAuth Tokens for Your Workplace.
Copy the Bot User OAuth Token.
Go back to Moogsoft Cloud and paste the token you just copied into the Token field.
Click Save.
Payload Body for CREATE Operation:
Open Slack. Within Slack, right click your notification channel and select Open channel details from the dropdown menu.
At the bottom of the pop-up window, copy the Channel ID.
Go back to Moogsoft Cloud.
Paste the following into the Key/Value Editor box. Make sure to replace the placeholder value with the Channel ID you copied from Slack:
{ "channel": "[YOUR_CHANNEL_ID]", "text": "ISSUE: $id || SEVERITY: $severity || TOTAL ALERTS: $total_alerts || DESCRIPTION $description || INCIDENT URL: $incident_url || CREATED AT: $created_at" }
Under Manage JSON variable type declarations, click Add Type Declaration.
Click Variable and select
$created_at
from the dropdown menu.Click Type and select Date and Time - Human-Readable Format (ISO 8601). This will make sure that the creation time is printed in human-readable format, instead of the default epoch format.
Map the Response Payload: External Name and ID:
Under External Webhook Target, select "Slack" from the dropdown menu.
UPDATE Notifications:
If you want to be notified when incidents or alerts change, enable update notifications.
Under Triggers, select the conditions that should trigger update notifications. If you wish to be notified of all changes that occur, select all the conditions.
Payload Body for UPDATE Operation:
Replace the pre-populated JSON in the Key/Value Editor with the following:
{ "channel": "[YOUR_CHANNEL_ID]", "text": "ISSUE: $id || SEVERITY: $severity || TOTAL ALERTS: $total_alerts || DESCRIPTION $description || INCIDENT URL: $incident_url || CREATED AT: $created_at", "thread_ts": "$external_id" }
Note
Note that this is the same JSON snippet used in the Payload Body for CREATE Operation, except with the addition of
"thread_ts": "$external_id"
. This will keep the update notification in the same message thread as the original notification.Under Manage JSON variable type declarations, click Add Type Declaration.
Click Variable and select
$created_at
from the dropdown menu.Click Type and select Date and Time - Human-Readable Format (ISO 8601). This will make sure that the creation time is printed in human-readable format, instead of the default epoch format.
Scroll up to the top of the page and click Test.
Save the integration.