Webhooks
This page covers two uses of webhooks with nps.today:
- Trigger a survey with a webhook: your system calls nps.today when something happens, and nps.today sends a survey.
- Get responses with a webhook: nps.today calls your URL when a new response arrives.
Trigger a survey with a webhook
If your system can send a webhook (an HTTP request to a URL when an event happens), you can point it at the nps.today API. Each call adds a campaign member to a campaign, and nps.today sends the survey by email or SMS.
At a glance
- Endpoint:
POST https://api.nps.today/campaigns/{campaignId}/respondent - You need: an API key and the campaign ID. See Create an API key and Find campaign IDs.
- Result: a new campaign member on the campaign, and a survey sent to the email address or phone number in the payload
Step 1: Set the endpoint
In your system's webhook settings, set the URL to:
https://api.nps.today/campaigns/{campaignId}/respondent
Replace {campaignId} with the campaign ID, shown as Internal ID in Campaign Info. The method is POST. See POST /campaigns/{campaignId}/respondent in the API reference.
Configure your system to send the webhook only for the events that should trigger a survey, for example when a ticket is closed.
Step 2: Set the authentication
Use the Authorization header, or basic authentication if your system only supports that. Both are described in Authentication and errors.
Step 3: Define the JSON payload
Not able to send a JSON payload?
If your webhook cannot send a JSON payload, a third-party system can help. Systems like Power Automate, Logic Apps and Zapier can listen to your webhook and send the payload. See Trigger Dixa surveys with Power Automate for an example.
Map the data from your system to the campaign member in nps.today. The example below uses {{...}} placeholders. Replace them with the placeholder syntax of your own system.
{
"respondent": {
"firstName": "{{merged.first_name}}",
"emailAddress": "{{merged.email.address}}",
"externalId": "{{merged.unique.id}}",
"phoneNumber": "{{merged.phone.number}}"
},
"custom": {
"segment": "{{A}}"
}
}
The custom object accepts any valid JSON. For all fields, see Trigger surveys and the API reference.
Step 4: Test your webhook
Test before you go live, with your own email address or phone number, or with real customer data and send-outs blocked. See Test an integration.
Verify it worked
- Trigger the event in your system, for example by closing a test ticket.
- Check the result in app.nps.today, as described in Test an integration.
- If no campaign member is added, check the API response in your system's webhook log. See Authentication and errors.
Still stuck? Contact us at [email protected].
Get responses with a webhook
You can have nps.today call a URL each time a response arrives. This is often used to start a task or a flow in another system based on a new response. There are two ways:
| Method | Set up in | Use it when |
|---|---|---|
| Webhook call on a campaign's NPS Notification trigger | The campaign editor in app.nps.today. See Webhook notification. | You want calls for one campaign, filtered by rating. |
| Webhook subscription through the API | WebHook endpoints in the API reference. See Get responses with a webhook subscription. |
You want calls for changes across your account, set up from your own system. |
If your URL requires authentication, add the credentials once as an external authentication method and select it on the trigger or webhook.
Webhook payload
The Webhook call on an NPS Notification trigger sends the response in this format. Click Test in the trigger to send an example to your URL.
Webhook raw content example
Below is an example of the content of the webhook call:
{
"DoNotContact":false,
"AgentRating":null,
"IsPublic":false,
"Sender":123,
"SurveyOpenedTime":"2023-04-17T09:28:25.7821525+00:00",
"ReminderOpenedTime":"2023-04-17T09:28:25.7821514+00:00",
"SurveySendTime":"2023-04-17T09:28:25.7821523+00:00",
"SurveyScheduledTime":"2023-04-17T09:28:25.7821523+00:00",
"ReminderScheduledTime":"2023-04-17T09:28:25.7821508+00:00",
"ReminderSendTime":"2023-04-17T09:28:25.7821508+00:00",
"SurveyBouncedTime":"2023-04-17T09:28:25.7821524+00:00",
"ReminderBouncedTime":"2023-04-17T09:28:25.7821513+00:00",
"History":null,
"OrgId":"7b923cd1-d919-4ad7-9e69-9bf13995438a",
"Device":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36",
"Answer1":"",
"Answer2":"",
"Answer3":"",
"Answer4":"",
"Answer5":"",
"MsCrmId":"Some Id for MsCrm",
"Custom":{},
"AllowedForPublicUse":false,
"SurveyAnswers":null,
"SurveyAnswersSimple":null,
"AdminComment":"Customer happy, no action required",
"AdminCommentBy":"Jane Doe",
"CampaignName":"Test Campaign",
"CampaignMemberId":56789,
"CampaignMembershipGuid":"4e1592e6-75b7-4f9b-9bb4-798636c234fc",
"ResponsibleEmployee":1234,
"Category":{
"Id":65,
"Name":"Payment"
},
"Respondent":{
"Id":1234,
"Address1":"Nowhere 1",
"Address2":"",
"City":"Notown",
"Country":"Denmark",
"ZipCode":"1234",
"EmailAddress":"[email protected]",
"FirstName":"John",
"LastName":"Doe",
"Active":true,
"Title":"Mr.",
"Company":{
"Id":1234,
"Name":"Testers Inc",
"EmailAddress":"[email protected]",
"Industry":"",
"Address1":"Somewhere",
"Address2":"",
"City":"Notown",
"Country":"",
"ZipCode":"1234",
"AccountNo":"1234",
"Segment":"",
"PhoneNumber":"12345678",
"PrimaryEmployee":null,
"Managers":null
},
"Employee":{
"Id":1324,
"Email":"[email protected]",
"FirstName":"Jane",
"LastName":"Doe",
"Title":"Ms",
"Department":"Acme Denmark",
"Team":"A-team",
"Division":"Primary",
"PhoneNumber":"12345678",
"Active":true,
"ExternalId":null
},
"Department":"Sales",
"PhoneNumber":"12345678",
"ExternalId":"677777685858"
},
"Id":1234567,
"Rating":7,
"RatingTime":"2023-04-17T09:28:25.7821482+00:00",
"Anon":false,
"RatingBy":"John Doe",
"UserComment":"This is a webhook, it works!",
"UserCommentBy":"John Doe",
"CommentTime":"2023-04-17T09:28:25.78215+00:00",
"CampaignId":1234,
"Closed":false
}