Skip to main content

Webhooks in testRTC

Some testRTC products come equipped with a notification system designed to catch a rich set of events within the system and inform you about your test results. This article will provide a clear guide on configuring the notification engine to seamlessly deliver test results to your specified endpoint.

Note: It is important to note that the information provided in this document is applicable to all testRTC products.
Tip: You can configure custom templates using Data Mapping. Custom templates can be used with Webhooks, and the Amazon Simple Notification Service. Learn more about Data Mapping at the end of this article.
Webhooks can be used for testing as well as monitoring. These are most often used for things like:
  • Notifications
  • Run results
  • Custom alerts

Webhook

When using webhooks there are two options that you can choose from.

  1. Simply paste the webhook URL. If you choose this option, we will be sending out the content in json/object format.
    https://webhook.site/80e9df96-8f69-4297-927a-00a28d723191
  2. Specify the exact format and headers.
    {
      // Specify the format of the payload: "json/object", "json/text", or "cloudevent"
      "format": "json/object",
      
      // URL where the webhook payload will be sent
      "url": "https://webhook.site/80e9df96-8f69-4297-927a-00a28d723191",
    
      // Headers to include in the webhook request
      "headers": {
        "Authorization": "Bearer eyJ0eXAi...",
        ...
      },
      
      // Optional
      // Parent field name encapsulating the primary data payload
      "fieldname": "anything-you-want",
      
      // Optional
      // Check Data Mapping section in this guide
      "body": { ... }
    }

Response Examples

  1. json/object
    {
        "_id": 123,
        "name": "obj"
    }
  2. json/text
    {
        "username": "testRTC_bot",
        "text": "{\"_id\":123,\"name\":\"obj\"}"
    }
  3. CloudEvents
    {
        "_id": 123,
        "name": "obj"
    }
    
    When using CloudEvents, further headers will be included by testRTC to identify the source and type.
    ce-source testrtc
    ce-type “testingrtc” “qualityrtc” “probertc” “none”
    Note: For more information, read CloudEvents.

Amazon Simple Notification Service (SNS)

There are two possible configurations when using Amazon SNS.

  1. If the SNS service is configured in one account (trusting) and the user is configured in another account (trusted), your configuration should look like this:
    {
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
        "roleArn": "arn:aws:iam::999999999999:role/Example",
        "topicArn": "arn:aws:sns:eu-central-1:999999999999:event",
    
        // Optional: Your schema for data mapping.
        "body": { ... }
    }
  2. In any case where the SNS service and user are configured in the same account, use the following configuration:
    {
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
        "topicArn": "arn:aws:sns:eu-central-1:999999999999:event",
    
        // Optional: Your schema for data mapping.
        "body": { ... }
    }
    

Response Example

(HTTP subscription)
{
    ...
    "Message": "{\"_id\":123, \"name\":\"obj\"}"
}

Data Mapping

You are allowed to map data and include custom fields in your response. To accomplish this, simply include a new "body" field in the configuration, outlining your mapping scheme.

  • Format
    {
        ...
        "body": {
            "MyCustomID": "Session 12: VPN enabled",
            "MyCustomField": "<%this.fieldName%>"
            }
    }
  • Data Example
    {
        "_id": "65afcc00332951a4e115c2f3",
        "name": "New Test",
        "project": {
            "_id": "83568359254fdj75847jfs99",
            "name": "My Cool Company"
        }
    }
  • Mapping Schema Example (JSON)
    {
        ...
        "body": {
            "testRunID": "<%this._id%>",
            "projectName": "<%this.project.name%>",
            "thereIsNoSuchField": "<%this.isItMonday%>"
        }
    }
  • DTO Example (mapping schema applied)
    {
        "testRunID": "65afcc00332951a4e115c2f3",
        "projectName": "My Cool Company",
        "thereIsNoSuchField": "UNKNOWN-VAR"
    }
  • Mapping Schema WITH “fieldname” Option Example (JSON)
    {
      ...
      "body": {
        "testRunID": "<%this._id%>",
        "projectName": "<%this.project.name%>",
    	"thereIsNoSuchField": "<%this.isItMonday%>"
      },
      "fieldname": "testResult"
    }
  • DTO Example (mapping schema & “fieldname” option applied)
    {
      "testResult": {
        "testRunID": "65afcc00332951a4e115c2f3",
        "projectName": "My Cool Company",
        "thereIsNoSuchField": "UNKNOWN-VAR"
      }
    }

Recommendations

  • Slack: When working with Slack webhooks, you should use json/text format for seamless integration.

Find Configuration Form in testRTC

Configuration for each product can be found in the following locations.
  • testingRTC / upRTC

  • qualityRTC

  • watchRTC

testingRTC / upRTC

Was this article helpful?

0 out of 0 found this helpful