Support & information center

Webhook formats

testRTC enables the use of webhooks to catch a rich set of events within the system. These include:

  1. testingRTC and upRTC test results, when a test run or a monitor run finishes
  2. qualityRTC network test results, when an end user conducts a network test

These webhooks can use different formats to fit the various third party systems you might be using.

Listed below are the formats supported and how to configure them.

URL only

If you place in the webhook the URL only, we will be sending it out as a JSON object.

https://dummy.url
Code language: JSON / JSON with Comments (json)

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" }
Code language: JSON / JSON with Comments (json)

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" }
Code language: JSON / JSON with Comments (json)

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" }
Code language: JSON / JSON with Comments (json)

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.testRun.usage_report.resultUrl%> failure:<% this.results.failureScreenshot %>`, } }
Code language: JSON / JSON with Comments (json)

Custom body templating

If none of the above fits your needs, you can also format our webhook as you see fit using our body templating format. Here is an example for it:

{ "url": "https://testrtc-webhook-director.netlify.app/.netlify/functions/slack-message-director", "body": { "testRunId": "<%this.testRunId%>", "testName": "<%this.testName%>", "runName": "<%this.runName%>", "runType": "<%this.runType%>", "status": "<%this.status%>", "error": "<%this.error%>", "additionalInfo": "<%this.additionalInfo%>", "projectName": "<%this.testRun.usage_report.projectName%>", "numberOfProbesSuccess": "<%this.testRun.usage_report.numberOfProbesSuccess%>", "numberOfProbesWarning": "<%this.testRun.usage_report.numberOfProbesWarning%>", "numberOfProbesFailure": "<%this.testRun.usage_report.numberOfProbesFailure%>", "actualTestTimeSec": "<%this.testRun.usage_report.actualTestTimeSec%>", "testRunStartDate": "<%this.testRun.usage_report.testRunStartDate%>", "testRunStartTime": "<%this.testRun.usage_report.testRunStartTime%>", "userName": "<%this.testRun.usage_report.userName%>", "score": "<%this.score%>", "failureReasons": "<%this.failureReasons%>", "input": "<%this.input%>", "resultUrl": "<%this.resultUrl%>", "failureScreenshot": "<%this.failureScreenshot%>", }, }
Code language: JSON / JSON with Comments (json)

Available variables can be found here.

Filtering webhooks

For testingRTC and upRTC, you may want to invoke the webhook only in certain conditions, such as a failed test. For this purpose, you can use the #webhook-filter run option. To that end, you can add something like this to you test run options:

#webhook-filter:error,warning
Code language: JavaScript (javascript)

The run option above means that the webhook will only be invoked if the test run ended with a status of error or warning.

Was this article helpful?

Related Articles