This document describes how to get a survey link inside a Kustomer Workflow.

AskNicely API

There is a new api endpoint for getting a survey link.

Url: https://<subdomain>.asknice.ly/api/v1/survey-link

Method: POST

Authorisation and headers:

"X-apikey": "<your api key>"
"Content-Type": "application/x-www-form-urlencoded"

Data (example):

"[email protected]"

You can send more information about the person you're surveying, and any custom data e.g.,

"[email protected]&name=Aaron Parker&segment=gold"

Success

{
    "success":true,
    "msg":"",
    "link":"<https://test.asknicely.site/s/abcde/>"
}

Failure

There could be a different message, depending on they failure reason:

{
    "success":false,
    "msg":"Contact has un-subscribed"
		   or "Contact has been surveyed x within the last x days"
       or "Contact created x days ago, rule is n days before first survey"
       or "Please upgrade your plan."
}

Kustomer Workflow

Here is an example step to get a survey link in json format

"steps": [    
    {
      "transitions": [
        {
          "target": "XXXX",
          "condition": {
            "op": "true",
            "values": [
              true
            ]
          }
        }
      ],
      "errorCases": [],
      "id": "XXXX",
      "action": "kustomer.rest-api.generic",
      "params": {
        "headers": {
          "Content-Type": "application/x-www-form-urlencoded",
          "X-apikey": "{{{variables.ABC}}}" // using a workflow variable 
        },
        "uri": "https://<domain>.asknice.ly/api/v1/survey-link",
        "method": "POST",
        "data": "",
        "json": true,
        "qs": { // Put the email address and any custom fields here
            "email": "[email protected]", // e.g., {{{steps.x.email}}}
            "name": "", // e.g., {{{steps.x.name}}}
            // include other custom data here to be imported into AskNicely
            "kustomer_conversationid": "{{{steps.1.id}}}" // for example,
            // when testing use obeyrules: **false**, so you always get a survey link
            "obeyrules": false
        }
      },
      "meta": {
        "displayName": "Get Survey Link"
      },
      "appVersion": "kustomer-^1.2.1"
    }
]

Example Workflow