Webhook integration examples

Example of OpsGenie Notification webhook setup

This configuration enables the integration of OpsGenie with the CAST AI console, ensuring that alerts are received in OpsGenie.

OpsGenie pre-requisite

Add an API integration

  1. Go to "Settings" → "Integrations".
  2. Run a search and select “API”.
  3. On the next screen, enter a name for the integration.
  4. Optional: Select a team in the "Assignee team" field if you want a specific team to receive alerts from the integration. Learn about the alert notifications flow in Opsgenie.
  5. Select "Continue". The integration is saved at this point.
  6. Expand the "Steps to configure the integration" section and copy the API key for use in your API requests.
  7. Select "Turn on integration." The rules you create for the integration will only work if you turn it on.
API key integration example

API key integration example

Define rules for creating and processing alerts

The configuration of an API integration involves defining many different alert scenarios. These scenarios specify how and when alerts can be created, closed, acknowledged, etc. The integration comes with a default set of alert creation and processing rules; you can customize them and add as many rules of your own as you like. For example, you can add three rules for create alert, which means the incoming data is evaluated against these three scenarios in order, and if one of them matches, an alert is created.

Alert rules example

Alert rules example

OpsGenie Integration

Add a Webhook integration

  1. Go to "Settings" > "Integrations".
  2. Select "Add integration".
  3. Run a search and select “Webhook”.
  4. On the next screen, enter a name for the integration.
  5. Optional: Select a team in the "Assignee team" if you want a specific team to receive alerts from the integration.
  6. Select "Continue". The integration is saved at this point.
  7. Select "Turn on integration." The rules you create for the integration will only work if you turn it on.

Sending alert descriptions and alert details is only available for "Create" and "Custom" actions.

Webhook integration example

Webhook integration example

Webhook configuration

Utilize the provided API integration key to configure your webhook integration, ensuring it is utilized for authentication purposes.

  • Webhook URL should be https://api.opsgenie.com/v2/alerts
  • Customer Header should include:
    • _Authorization: GenieKey
    • _Content-Type: application/json

Webhook integration validation

Before entering the essential details into the CAST AI webhook configuration, we recommend executing the following curl command. This action will verify whether the configured integration receives alerts and notifications as anticipated:

curl -X POST https://api.opsgenie.com/v2/alerts \
    -H "Content-Type: application/json" \
    -H "Authorization: GenieKey <API Key>" \  
    -d '{"message": "An example alert message"}'
OpsGenie Alert

OpsGenie Alert

CAST AI Integration

Add webhook via CAST AI console

  • Navigate to "Notifications" > "Add Webhook".

  • Set up the fields below using the information collected from the Webhook and API integration

    • Name of Webhook
    • Callback URL
    • Category
    • Severity
    • Request template
    • Authorization keys (Headers)
Webhook “Can connect” example

Webhook “Can connect” example

Example of MS Teams Notification webhook setup

This configuration enables the integration of MS Teams with the CAST AI console, ensuring that alerts are received in MS Teams.

Method 1: MS Teams Incoming Webhook Integration

Create an Incoming Webhook

  1. In the New Teams client, select Teams and navigate to the channel where you want to add an Incoming Webhook.

  2. Select "More options" (•••) on the right side of the channel name.

  3. Select "Manage channel".

  4. Select "Edit".

  5. Search for "Incoming Webhook" and select "Add."

  6. Select "Add".

📘

Note

If you’ve already added an Incoming Webhook before, the Configure option appears instead of Add. Select Configure to create another Incoming Webhook.

  1. Provide a name for the webhook and upload an image if necessary.

  2. Select "Create".

  3. Copy and save the unique webhook URL present in the dialog. The URL maps to the channel, and you can use it to send information to Teams.

  4. Select "Done". The webhook is now available in the Teams channel.

CAST AI Integration

Add webhook via CAST AI console

  • Navigate to "Notifications" > "Add Webhook".

  • Set up the fields below using the information collected from the Webhook and API integration
    • Name of Webhook
    • Callback URL
    • Category
    • Severity
    • Request template
    • Authorization keys (Headers)

After setting up the webhook, you should see notifications in your designated Teams channel when CAST AI triggers it. The notifications will appear as cards in the channel, displaying relevant information from CAST AI.

Test Notification

Method 2: MS Teams Workflows Integration

This method uses the Workflows feature in MS Teams to set up notifications from CAST AI.

Set up the Teams workflow

  1. In Microsoft Teams, select the channel where you want to set up the notification workflow.
  2. Click the "More options" (•••) button next to the channel name.
  3. Select "Workflows" from the dropdown menu.
  1. In the "Workflows" panel, scroll down and select "Post to a channel when a webhook request is received".
  1. Select the team and channel you want to use, then click "Add workflow."
  1. Once added, you'll receive a Webhook URL. Copy this URL, as you'll need it for the CAST AI configuration described below.

Configure CAST AI to use the Teams workflow

  1. In the CAST AI console, navigate to "Notifications" > "Add Webhook."
  1. Fill in the following details:

    • Name of Webhook
    • Callback URL (use the webhook URL copied from Teams)
    • Category
    • Severity
    • Request template (you can use the sample payload template provided below)
    {
      "type": "message",
      "attachments": [
        {
          "contentType": "application/vnd.microsoft.card.adaptive",
          "content": {
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
              {
                "type": "TextBlock",
                "text": "{{ .Cluster.Name }}",
                "size": "Large",
                "weight": "Bolder",
                "color": "Attention",
                "horizontalAlignment": "Center"
              },
              {
                "type": "TextBlock",
                "text": "{{ .Message }}",
                "wrap": true,
                "spacing": "Medium"
              }
            ]
          }
        }
      ]
    }
    
    • Authorization keys (Headers): Set to application/json
  1. Click "Add" to create the webhook in CAST AI.

After setting up the webhook, you should see notifications in your designated Teams channel when CAST AI triggers it. The notifications will appear as cards in the channel, displaying relevant information from CAST AI.