Send Slack Messages with TestingBot Webhooks
With the Slack webhook template, you get a message in your Slack channel whenever a test completes, or only when a test fails. The message shows the test result, the browser, platform and duration, plus a button that opens the test details page with video, logs and screenshots.
Prerequisites
You need a Slack incoming webhook URL for the channel where messages should appear:
-
Create a Slack app for your workspace (or open an existing one) at
api.slack.com/apps. - In the app settings, open Incoming Webhooks and activate them.
- Click Add New Webhook to Workspace and pick the target channel.
-
Copy the generated
https://hooks.slack.com/services/...URL.
Prefer a richer Slack experience? TestingBot also offers a native Slack integration with slash commands, URL unfurling and test event notifications, without writing any payloads.
Set up the webhook in TestingBot
- Log in to the member area and go to the Webhooks page.
- Click Create webhook.
- Under Start from a template, pick the Slack tile. This prefills the HTTP method and the payload body.
-
Paste your
https://hooks.slack.com/services/...URL in the URL field. - Adjust the triggers: failures only or all tests, the test type and an optional name filter.
- Click Create webhook at the bottom of the form to save the configuration.
Template payload
The Slack template sends this Block Kit payload:
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Test {{TEST_STATUS}}: {{TEST_NAME}}"
}
},
{
"type": "section",
"fields": [
{ "type": "mrkdwn", "text": "*Browser:* {{BROWSER_NAME}} {{BROWSER_VERSION}}" },
{ "type": "mrkdwn", "text": "*Platform:* {{PLATFORM}}" },
{ "type": "mrkdwn", "text": "*Duration:* {{TEST_DURATION}} seconds" }
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": { "type": "plain_text", "text": "View test" },
"url": "{{TEST_URL}}"
}
]
}
]
}
There are no placeholders to replace in this payload: the Slack channel is determined by the webhook URL itself.
The {{...}} tokens are substituted with the values of the test that triggered the webhook; the full list is on the built-in variables page.
Test it
Click Test Webhook in the form to send a sample request with example values.
On success, a message appears in your Slack channel within a few seconds and the Response panel shows a 200 status with the body ok.
If nothing arrives, check for these common causes:
- The webhook URL is incomplete or was revoked in Slack.
- Incoming webhooks are not activated for your Slack app.
- The payload JSON was edited and is no longer valid; Slack responds with
invalid_payload.
Related: Webhooks Quick Start, all webhook templates and the Microsoft Teams walkthrough.