Skip to main content

Invite Options JSON structure

When generating a qualityRTC invite, you can have query parameters included such as region or account. You can also use these invites to add any additional fields you might need.

This is something you can configure using the Options JSON field of the invite:

JSON format

The Options JSON follows the following format:
{
  "fields": [

    // array of optional fields
  ],
  "queryParams": {
    // query params tuples
  }
}

You can place in the options either the fields or the queryParams or both as needed.

Adding optional fields

You can add custom optional fields to the network test which the user will need to fill in. This is useful if you’d like to collect additional information about the user, such as the location of the test (home or office), network type, etc.

The fields will be placed in the log and in the webhook.

Here’s how this component is formatted:
"fields": [
  {
    "name": "<field name>",
    "label": "<field label>",
    "variant": "<text|select>",
    "required": <true|false>
  },
  .
  .
  .
]

fields is an array where each element is structured with the following information:

  • name – the name of the field. This is how you will see the field in the log and on the webhook
  • label – the label to show on the field for the user
  • variant – type of field. Currently, text and select are supported
  • required – is this field mandatory to fill out or not

Per the variant of the field you may or may not need to add additional values to it.

Text field

Text fields are simple text entries that the user can fill out.

There are no additional configuration for such fields necessary.

Selection field

Selection fields are dropdown menus for the user to select from:
"fields": [
  {
    "name": "<field name>",
    "label": "<field label>",
    "variant": "select",
    "required": <true|false>,
    "options": [
      {
        "label": "<instruction>",
        "value": "none"
      },
      {
        "label": "<label to show>",
        "value": "<value if selected>"
      },
      .
      .
      .
    ]
  },
  .
  .
  .
]

The options now include an array of selection alternatives.

Each selection has a label and a value. The label is displayed to the user while the value is what will be placed in the log and the webhook if this option is selected.

You can add a first selection with a value of “none” which will place the label as an instruction to the user.

Example:
{
  "fields": [
    {
      "name": "work",
      "label": "Work",
      "variant": "select",
      "required": true,
      "options": [
        {
          "label": "Select work place...",
          "value": "none"
        },
        {
          "label": "Working from home",
          "value": "Working from home"
        },
        {
          "label": "Working remotely",
          "value": "Working remotely"
        }
      ]
    }
  ]
}

Adding query parameters

To add query parameters as part of the invite, use the following JSON structure:
  "queryParams": {
    "<key1>": "<value1>",
    "<key2>": "<value2>"
    .
    .
    .
  }

Each key represents a query parameter and value its value.

The following would act as if you used /?account=acme in the URL:
"queryParams": {
  "account": "acme"
}

Was this article helpful?

0 out of 0 found this helpful