Skip to content

Trigger a survey after an event in Dixa

This documentation will guide you on how to trigger a survey from Dixa using Dixa webhook and a third party system to create the needed logic. This documentation will use Logic Apps.

Prerequisites

Create a campaign via the nps.today platform and obtain the CampaignID:

CampaignID

In this example – the CampaignID is 13544

Also, an API key is required. See here where to find or create your API keys.

Create a webhook in Dixa

The first step is to send a nps.today survey after for example a closed conversation. The current solution for completing that task is to set up a Webhook like this:

Dixa webhook

See this chapter on how to generate the webhook URL.

See example of the webhook payload here
    {
        "event_id": "2ec6bb79-3951-4c56-9d32-66e6ba9381db",
        "event_fqn": "CONVERSATION_CLOSED",
        "event_version": "1",
        "event_timestamp": "2023-01-31T15:56:25.694Z",
        "organization": {
            "id": "4aac76a9-3b37-431a-9a05-a86605b5c3bb",
            "name": "NPS.Today"
        },
        "data": {
            "conversation": {
                "csid": 18,
                "channel": "EMAIL",
                "status": "CLOSED",
                "direction": "INBOUND",
                "queue": {
                    "id": "986359e5-e201-48ab-84af-c7799e03e58c",
                    "name": "Inbound support"
                },
                "contact_point": "npstoday-fr@email.dixa.io",
                "requester": {
                    "id": "d1bb9286-bf5a-42d6-b4d3-aaceef0d1e38",
                    "name": "John Doe",
                    "email": "JohnDoe@hotmail.com",
                    "phone": "+4512345678",
                    "roles": [
                        "Enduser"
                    ]
                },
                "assignee": {
                    "id": "c25bf883-9727-4632-81c3-8ec8f8ff26fd",
                    "name": "John Doe",
                    "email": "JohnDoe@npstoday.com",
                    "phone": null,
                    "roles": [
                        "Admin",
                        "Agent"
                    ]
                },
                "subject": "Low battery",
                "tags": [],
                "created_at": "2023-01-31T15:56:09.187Z"
            }
        }
    }

See this Dixa webhook guide to learn more about setting up webhook in Dixa.

Listen to the webhook

Now we need to listen to the webhook, to know when a conversation is closed. This is where we need a third-party system to help us. This guide uses Logic Apps, but other systems like Power Automate and Zapier can be used as well.

Create the logic

Create the Trigger

Start by creating a trigger using “When a HTTP request is received”. This will generate a URL that you need for your webhook in Dixa.
The webhook is generated when you save the Logic App.

Also use the payload from above as a “sample payload to generate schema”

HTTP request received

Create your Conditions

Now you need to create your conditions that will filter the relevant HTTP requests, that need to trigger a survey in nps.today.

Condtions

In this case we have created 4 conditions:

  • Conversation status needs to be “CLOSED”
  • Phone number needs to contain a “+” (to make sure we have a phone number because we need to send out survey in a text message)
  • The requester name is grater than “a” (this is to make sure we have a name on the requester, if needed)
  • Channel needs to be a “PSTN_PHONE” (Phone channel)

If the conditions are not met, then stop the process.

If they are met create a new Condition. This Conditions is made to be sure, that the Conversation status is “CLOSED”

Condition 2

Create your Action

If the Status is still “CLOSED” create a HTTP request action.

Action

Fill the fields with the following

Method: POST

URL:

https://api.nps.today/campaigns/{{campaignId}}/respondent

Headers:
Authentication: APIKEY {your nps.today api key}
Content-Type: application/json

Body (data you need on the recipient of the survey):

[
{
"Respondent": {
      "firstName": "{{merged.requester.first_name}}",
      "emailAddress": "{{{{merged.requester.email.address}}",
      "employee": {
        "email": "{{merged.user.email.address}}",
        "firstname": "{{merged.user.first_name}}"
      },
      "externalID": "{{merges.requester.id}}",
      "phonenumber": "{{merged.requester.phone.number}}"
    },
    "custom":
    {
    "conversationid":"{{merged.conversation.csid}}"
    }
}
]

See more information about the body here.

Now save the process and activate it.

Sum-up

Now we have created a trigger in Dixa, that sends out a text message survey to the requester every time a conversation is Closed, that has phone number, is a Phone Channel, and have a requester name.