testRTC enables the use of webhooks to catch a rich set of events within the system. These can be used for testing as well as monitoring. These are most often used for things like;
- Notifications
- Run results
- Custom alerts
URL only
If you place in the webhook the URL only, we will be sending it out as a JSON object.
https://dummy.url
JSON object
The webhook configuration below sends the information as a JSON object in the body of the message.
{
"format": "json/object",
"url": "https://dummy.url"
}
JSON text format
If you are planning to integrate the webhook with something like Slack or Zapier, then the best approach is to use a JSON text format, where we “stringify” the information.
{
"format": "json/text",
"url": "https://dummy.url"
}
You can read more on sending test results via webhook to Slack.
CloudEvents
Here is how to send our webhooks as CloudEvents v1.0 format:
{
"format": "cloudevent",
"url": "https://dummy.url"
}
The above will send the webook to “url” formatting the body of the message as CloudEvents format.
Amazon SNS
If you plan on sending the webhook to Amazon Simple Notification Service, then you can use the following format:
{
"provider": "aws-sns",
"secretAccessKey": "xxx",
"region": "xxx",
"accessKeyId": "xxx",
"roleArn": "xxx",
"topicArn": "xxx",
"body": {
"Server": "TestRTC",
"Instance": "<%this.runName%>",
"Severity": "TestRTC",
"Message": `testRTC Alert for <%this.testName%>
<%this.runName%>
error:<%this.error%>
url:<%this.resultUrl%>
failure:<% this.failureScreenshot %>`,
}
}
Custom body templating (limited application)
Note: Custom body templating is not available for all products. It can only be used with testingRTC and upRTC
For testingRTC and upRTC, you can also format our webhook as you see fit using our body templating format. Below is an example for it.
{
"url": "https://testrtc-webhook-director.netlify.app/.netlify/functions/slack-message-director",
"body": {
"testRunId": "<%this.testRunId%>",
"testName": "<%this.testName%>",
"userName": "<%this.userName%>",
"projectName": "<%this.projectName%>",
"projectId": "<%this.projectId%>",
"status": "<%this.status%>",
"concurrentUsers": "<%this.concurrentUsers%>",
"numberOfProbesSuccess": "<%this.numberOfProbesSuccess%>",
"numberOfProbesWarning": "<%this.numberOfProbesWarning%>",
"numberOfProbesFailure": "<%this.numberOfProbesFailure%>",
"totalTestTimeMin": "<%this.totalTestTimeMin%>",
"score": "<%this.score%>",
"runName": "<%this.runName%>",
"runType": "<%this.runType%>",
"error": "<%this.error%>",
"additionalInfo": "<%this.additionalInfo%>",
"failureReasons": "<%this.failureReasons%>",
"failureScreenshot": "<%this.failureScreenshot%>",
"resultUrl": "<%this.resultUrl%>"
}
}
Custom variables
You can pass certain variables to the webhook in its advanced format. This is useful for collecting information and when you want to format the message itself.
Variable | Description |
testRunId | Identifier of the specific test execution |
testName | The name of the test script |
projectName | The name of the testRTC project running this test |
runName | The random name allocated for the specific test execution |
runType | The type of execution. Will be either test or monitor |
status | The status of the test execution (essentially, if it succeeded or failed) |
error | Associated error message in case the test failed |
additionalInfo | The information provided via rtcSetAdditionalInfo() |
failureReasons | Textual reason for failure |
failureScreenshot | URL to the screenshot taken on failure, if such exist |
score | Media score for the test execution |
resultUrl | URL to the test result for easy access |
concurrentUsers | Total number of probes in the test execution |
numberOfProbesSuccess | Number of probes in the test execution with a successful result status |
numberOfProbesWarning | Number of probes in the test execution with a warning result status |
numberOfProbesFailure | Number of probes in the test execution with a failure result status |
totalTestTimeMin | Full length of the test execution in minutes |
userName | The name of the user who executed the test |
Note: You can integrate these variables anywhere in the body section of your webhook by placing them in <% %>
For example:
{
"url":"https://webhook-destination.com",
"body":{
"testRunId":"<%this.testRunId%>",
"testName":"<%this.testName%>",
"runName":"<%this.runName%>",
"status":"<%this.status%>",
"error":"<%this.error%>"
}
}