Skip to main content

Open OpsGenie Alerts when Tests Fail

With the OpsGenie webhook template, TestingBot creates an alert in OpsGenie whenever a test completes, or only when it fails. The alert carries the test name, status, browser, platform and a link to the test details page, so the on-call responder sees everything needed to triage the failure.

The template posts to the OpsGenie Alert API and authenticates with an API key in the Authorization header.

Prerequisites

You need an OpsGenie API key from an API integration:

  1. In OpsGenie, go to Settings and open Integrations (or open the team that should receive the alerts and use its Integrations tab).
  2. Add an API integration and make sure it has create alert access.
  3. Copy the API key that OpsGenie generates for the integration.

The key is sent in an Authorization header with the value GenieKey YOUR_OPSGENIE_API_KEY. The webhook URL is the fixed endpoint https://api.opsgenie.com/v2/alerts. If your OpsGenie account is hosted in the EU region, use https://api.eu.opsgenie.com/v2/alerts instead.

Set up the webhook in TestingBot

  1. Log in to the TestingBot member area and open the Webhooks page under Integrations.
  2. Click Create webhook and give it a name, for example OpsGenie alerts.
  3. Under Start from a template, pick the OpsGenie tile. This prefills the URL https://api.opsgenie.com/v2/alerts, the POST method, the payload below and an Authorization header in the Headers tab.
  4. In the Headers tab, replace YOUR_OPSGENIE_API_KEY in the header value GenieKey YOUR_OPSGENIE_API_KEY with the API key you copied.
  5. Set the trigger to failures only if you only want alerts for failing tests. Optionally narrow it down with a test type or a name filter such as regression_*.
  6. Click Create webhook at the bottom of the form to save the configuration.

Template payload

The OpsGenie template sends this JSON body. There are no placeholders to edit inside the body itself: your API key lives in the Authorization header instead. The {{...}} tokens are substituted with test values at delivery time and are documented on the built-in variables page.

{
  "message": "Test {{TEST_STATUS}}: {{TEST_NAME}}",
  "description": "Test {{TEST_NAME}} finished with status {{TEST_STATUS}} on {{PLATFORM}}. View it at {{TEST_URL}}",
  "priority": "P3",
  "details": {
    "test_id": "{{TEST_ID}}",
    "browser": "{{BROWSER_NAME}} {{BROWSER_VERSION}}",
    "platform": "{{PLATFORM}}",
    "test_url": "{{TEST_URL}}"
  }
}

The alert message shows the test result and name, the description includes the platform and a link, and the details section adds structured meta-data. Everything stays editable: you can raise the priority to P1, add tags or responders, or extend details with more variables.

Test it

Click Test Webhook in the form to send a sample alert with placeholder test values. The response panel shows the HTTP status, duration, headers and body returned by OpsGenie; a successful request returns a 202 status with a requestId in the body, and a new alert appears in your OpsGenie alert list.

If no alert shows up, check these common causes:

  • The Authorization header still contains the YOUR_OPSGENIE_API_KEY placeholder, or the key is wrong; OpsGenie responds with a 401 or 403 status in that case.
  • The API integration is disabled or lacks create alert access.
  • Your account is in the EU region but the webhook still points at the US endpoint.
Was this page helpful?
Last updated