Skip to content

Relay

What is Relay?

Relay is a module that works like a logic gate for processing respondents. It can be configured to send the respondent data to a specific endpoint instead of directly sending to the nps.today database. This is useful if you want to apply a custom logic for adding respondents.

When to use Relay?

A common use case is when you want to add respondents to a campaign based on a custom logic. For example, you want to add respondents to a campaign only if certain criteria are met. Since we do not hold this information, you need to write a logic that checks for that in your own system. In this case, you can configure Relay to send the respondent data to a custom endpoint that will check for the amount the customer spent and then, send the data to nps.today.

Relay diagram

Limitations

The Relay module is only available for the following integrations:

  • Miralix
  • Dixa
  • 3Kontakt
  • Telia Touchpoint
  • Dstny
  • Tele2

We are working on adding support for other integrations and for manual send-outs. Contact our support if you need this feature for your specific integration.

What is in the data sent to the endpoint?

The payload is the same as the one sent to the nps.today API for adding respondents. The difference is that we include the campaignId in the payload.

For all fields, see POST /campaigns/{campaignId}/respondents in the API reference.

Here is an example:

[
    {
        "campaignId": 5000,
        "respondent": {
            "address1": "Surveystreet 42",
            "city": "Copenhagen",
            "country": "Denmark",
            "zipCode": "1000",
            "emailAddress": "[email protected]",
            "firstName": "John",
            "lastName": "doe",
            "title": "Mr.",
            "company": {
                "name": "Acme INC.",
                "emailAddress": "[email protected]",
                "industry": "Outdoor Equipment"
            },
            "phoneNumber": "+4512345678"
        },
        "note": "The customer bought several items, seemed very happy",
        "employee": {
            "email": "[email protected]",
            "firstName": "Jane",
            "lastName": "Doe",
            "title": "Customer Relations Expert",
            "department": "Customer Service",
            "team": "A",
            "division": "Nordics",
            "externalId":"jd1234"
        },
        "sender": {
            "email": "[email protected]",
            "firstName": "Jane",
            "lastName": "Doe"
        },
        "doNotContact": false,
        "custom": {
            "key1": "Put any valid json here, note that this is still partly in development",
            "key2": "Some data from a phone system"
        }
    }
]

How to configure Relay?

You need to be an Administrator to configure Relay.

  1. In the left menu, under Management, click Account.
  2. Select the Relay tab. By default, Relay is turned off.

    The Relay tab with Relay turned off

  3. Turn on the Relay switch.

    The Relay tab with Relay turned on

  4. In Type, select External.

  5. In Webhook URL, enter the URL of your endpoint. nps.today sends the respondent data here.
  6. In Authentication, select how nps.today authenticates with your endpoint:
    • None: the data is sent without authentication.
    • Basic: enter a user name and a Password.
    • API Key: enter the API Key your endpoint expects.
    • OAuth: enter the Client ID, Client Secret, Token Endpoint URL and Authorization Source (the scope).
  7. Click Save Changes.

You can also manage the Relay setting from your own system with the RelaySetting endpoints in the API reference.

Relay takes over adding respondents

When Relay is on, nps.today no longer adds respondents from the supported integrations itself. The data is sent to your endpoint, and your endpoint must add the respondents to nps.today through the API, for example with POST /campaigns/{campaignId}/respondents.

Testing

To test Relay, send a POST request to this endpoint, https://functions.nps.today/api/relay/, with a tool like Postman, and use a tool like Webhook.site to check the data sent.

Use the webhook URL as the Relay URL:

webhook url

Set that as your relay config:

relay config

Send a POST request:

curl --location 'https://functions.nps.today/api/relay/' \
    --header 'Content-Type: application/json;charset=UTF-8' \
    --header 'Authorization: apikey <your API key>' \
    --data-raw '{
        "campaignId": 5000,
        "respondent": {
            "emailAddress": "[email protected]",
            "firstName": "John",
            "lastName": "Doe",
            "phoneNumber": "+4512345678"
        },
        "custom": {
            "callDuration": "some content",
            "val2": 12
        }
    }'
Then check the data received on the webhook site, including the authentication you chose:
The relay data received on Webhook.site

Verify it worked

  1. Trigger a survey from your integration, for example with a test call.
  2. Check that your endpoint receives the data with the campaignId.
  3. Check that your endpoint adds the respondent to nps.today: open the campaign in app.nps.today and find the new campaign member.