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
- Go to "Settings" → "Integrations".
- Run a search and select “API”.
- On the next screen, enter a name for the integration.
- 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.
- Select "Continue". The integration is saved at this point.
- Expand the "Steps to configure the integration" section and copy the API key for use in your API requests.
- Select "Turn on integration." The rules you create for the integration will only work if you turn it on.
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.
OpsGenie Integration
Add a Webhook integration
- Go to "Settings" > "Integrations".
- Select "Add integration".
- Run a search and select “Webhook”.
- On the next screen, enter a name for the integration.
- Optional: Select a team in the "Assignee team" if you want a specific team to receive alerts from the integration.
- Select "Continue". The integration is saved at this point.
- 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 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"}'
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)
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
-
In the New Teams client, select Teams and navigate to the channel where you want to add an Incoming Webhook.
-
Select "More options" (•••) on the right side of the channel name.
-
Select "Manage channel".
-
Select "Edit".
-
Search for "Incoming Webhook" and select "Add."
-
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.
-
Provide a name for the webhook and upload an image if necessary.
-
Select "Create".
-
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.
-
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
- In Microsoft Teams, select the channel where you want to set up the notification workflow.
- Click the "More options" (•••) button next to the channel name.
- Select "Workflows" from the dropdown menu.
- In the "Workflows" panel, scroll down and select "Post to a channel when a webhook request is received".
- Select the team and channel you want to use, then click "Add workflow."
- 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
- In the CAST AI console, navigate to "Notifications" > "Add Webhook."
-
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
- 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.
Updated 2 months ago