Send notifications to Slack

You can configure Moogsoft Cloud to send alert or incident notifications to Slack using the Slack API. The following steps describe the workflow.

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 Slack notification channel

  1. Go to api.slack.com.

  2. Click Create an app > From scratch.

  3. Provide a name for the app and select a workspace. Then click Create App.

  4. Enable incoming webhooks:

    1. Navigate to Features > Incoming Webhooks.

    2. Click the slider to enable the feature.

  5. Configure OAuth and permissions:

    1. Navigate to Features > OAuth & Permissions.

    2. 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.

    3. Under OAuth Tokens for Your Workplace, click Request to Install.

    4. Fill out a request message and submit the request.

  6. Once your administrators approve the installation request, open Slack.

  7. Within Slack, create a new channel.

  8. Navigate back to api.slack.com.

  9. 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.

  10. Select the new Slack channel you created and click Allow.

  11. Open Slack. Within Slack, right click your new channel and select Open channel details from the dropdown menu.

  12. Navigate to Integrations > Apps and click Add an App.

  13. Type the name of the app into the search bar and add it to the channel.

Set up outbound webhook in Moogsoft Cloud

  1. Within Moogsoft Cloud, navigate to Outbound Integrations > Webhook.

  2. Click Add a Webhook and complete each section according to the following:

    1. Name and Scope:

      1. Provide a unique name and select the type of data that should be sent to Slack (incidents or alerts).

      2. Within the filter section, add conditions to control which incidents or updates are forwarded to Slack.

    2. CREATE Operations and HTTP Configuration:

      1. Set the request method as POST.

      2. Copy and paste the following URL:

        https://slack.com/api/chat.postMessage
      3. Under Authorization, select "Bearer Token" from the dropdown menu.

      4. Click Add New Credentials and provide a name.

      5. Go to api.slack.com and navigate to Features > OAuth & Permissions > OAuth Tokens for Your Workplace.

      6. Copy the Bot User OAuth Token.

      7. Go back to Moogsoft Cloud and paste the token you just copied into the Token field.

      8. Click Save.

    3. Payload Body for CREATE Operation:

      1. Open Slack. Within Slack, right click your notification channel and select Open channel details from the dropdown menu.

      2. At the bottom of the pop-up window, copy the Channel ID.

      3. Go back to Moogsoft Cloud.

      4. 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"
        }
      5. Under Manage JSON variable type declarations, click Add Type Declaration.

      6. Click Variable and select $created_at from the dropdown menu.

      7. 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.

    4. UPDATE Notifications:

      1. If you want to be notified when incidents or alerts change, enable update notifications.

      2. 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.

    5. Payload Body for UPDATE Operation:

      1. 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.

      2. Under Manage JSON variable type declarations, click Add Type Declaration.

      3. Click Variable and select $created_at from the dropdown menu.

      4. 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.

  3. Scroll up to the top of the page and click Test.

  4. Save the integration.