How to send a Voice Survey using Conversation API

Routee's Voice Converastion API helps you to create and send Voice Surveys to gain valuable feedback from your customers about your products or services.

You can use the voice survey to be informed about customer's complaints or how satisfied are with the service that they received. When a customer completes a survey, Routee sends the gathered tones to the eventUrl that you set when you created the voice conversation.

You are able to track the survey reports and use them to improve your products and services.

Example of a Voice Survey:

Your Header should contain authorization and content type:

KEYVALUE
AuthorizationBearer {access_token}
Content-Typeapplication/json

An example request is shown below:

curl -X POST \
  https://connect.routee.net/voice/conversation \
  -H 'authorization: Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2' \
  -H 'content-type: application/json' \
  -d '{
  "from": "Company",
  "to": {
    "phone": "+30691111111"
  },
  "dialPlan": {
    "verbs": [
      {
        "type": "SAY",
        "message": {
          "language": "en-GB",
          "gender": "female",
          "text": "You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement."
        }
      },
      {
        "type": "SAY",
        "message": {
          "language": "en-GB",
          "gender": "female",
          "text": "I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree."
        }
      },
      {
        "type": "PAUSE",
        "duration": 3
      },
      {
        "type": "SAY",
        "message": {
          "language": "en-GB",
          "gender": "female",
          "text": "I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree."
        }
      },
      {
        "type": "PAUSE",
        "duration": 3
      },
      {
        "type": "SAY",
        "message": {
          "language": "en-GB",
          "gender": "female",
          "text": "Thank you very much for participating in this valuable survey!"
        }
      },
      {
        "type": "COLLECT",
        "eventUrl": "http://www.example.com",
        "maxDigits": 2,
        "submitOnHash": false
      }
    ]
  }
}'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"from\":\"Company\",\n  \"to\":{\"phone\":\"+30691111111\"},\n  \"dialPlan\": {\n      \"verbs\":[\n      \n        {\n        \t \"type\": \"SAY\",\n           \"message\": {\n              \"language\": \"en-GB\",\n              \"gender\": \"female\",\n              \"text\": \"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement.\"\n            }\n        },\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n            \t  \"gender\": \"female\",\n              \t\"text\": \"Thank you very much for participating in this valuable survey!\"\n            }\n        },\n        {\n           \"type\": \"COLLECT\",\n\t         \"eventUrl\": \"http://www.example.com\",\n           \"maxDigits\": 2,\n           \"submitOnHash\": false\n        }]\n  }\n}");
Request request = new Request.Builder()
  .url("https://connect.routee.net/voice/conversation")
  .post(body)
  .addHeader("authorization", "Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/voice/conversation");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2");
request.AddParameter("undefined", "{\n  \"from\":\"Company\",\n  \"to\":{\"phone\":\"+30691111111\"},\n  \"dialPlan\": {\n      \"verbs\":[\n      \n        {\n        \t \"type\": \"SAY\",\n           \"message\": {\n              \"language\": \"en-GB\",\n              \"gender\": \"female\",\n              \"text\": \"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement.\"\n            }\n        },\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n            \t  \"gender\": \"female\",\n              \t\"text\": \"Thank you very much for participating in this valuable survey!\"\n            }\n        },\n        {\n           \"type\": \"COLLECT\",\n\t         \"eventUrl\": \"http://www.example.com\",\n           \"maxDigits\": 2,\n           \"submitOnHash\": false\n        }]\n  }\n}", ParameterType.RequestBody); ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/voice/conversation",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_POSTFIELDS => "{\n  \"from\":\"Company\",\n  \"to\":{\"phone\":\"+30691111111\"},\n  \"dialPlan\": {\n      \"verbs\":[\n      \n        {\n        \t \"type\": \"SAY\",\n           \"message\": {\n              \"language\": \"en-GB\",\n              \"gender\": \"female\",\n              \"text\": \"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement.\"\n            }\n        },\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n            \t  \"gender\": \"female\",\n              \t\"text\": \"Thank you very much for participating in this valuable survey!\"\n            }\n        },\n        {\n           \"type\": \"COLLECT\",\n\t         \"eventUrl\": \"http://www.example.com\",\n           \"maxDigits\": 2,\n           \"submitOnHash\": false\n        }]\n  }\n}",
  CURLOPT_HTTPHEADER => array(
    "authorization: Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("connect.routee.net")

payload = "{\n  \"from\":\"Company\",\n  \"to\":{\"phone\":\"+30691111111\"},\n  \"dialPlan\": {\n      \"verbs\":[\n      \n        {\n        \t \"type\": \"SAY\",\n           \"message\": {\n              \"language\": \"en-GB\",\n              \"gender\": \"female\",\n              \"text\": \"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement.\"\n            }\n        },\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n            \t  \"gender\": \"female\",\n              \t\"text\": \"Thank you very much for participating in this valuable survey!\"\n            }\n        },\n        {\n           \"type\": \"COLLECT\",\n\t         \"eventUrl\": \"http://www.example.com\",\n           \"maxDigits\": 2,\n           \"submitOnHash\": false\n        }]\n  }\n}"

headers = {
    'authorization': "Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2",
    'content-type': "application/json"
    }

conn.request("POST", "/voice/conversation", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://connect.routee.net/voice/conversation")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["authorization"] = 'Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2'
request["content-type"] = 'application/json'
request.body = "{\n  \"from\":\"Company\",\n  \"to\":{\"phone\":\"+30691111111\"},\n  \"dialPlan\": {\n      \"verbs\":[\n      \n        {\n        \t \"type\": \"SAY\",\n           \"message\": {\n              \"language\": \"en-GB\",\n              \"gender\": \"female\",\n              \"text\": \"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement.\"\n            }\n        },\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n            \t  \"gender\": \"female\",\n              \t\"text\": \"Thank you very much for participating in this valuable survey!\"\n            }\n        },\n        {\n           \"type\": \"COLLECT\",\n\t         \"eventUrl\": \"http://www.example.com\",\n           \"maxDigits\": 2,\n           \"submitOnHash\": false\n        }]\n  }\n}"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/voice/conversation",
  "method": "POST",
  "headers": {
    "authorization": "Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2",
    "content-type": "application/json"
  },
  "processData": false,
   "data": "{\n  \"from\":\"Company\",\n  \"to\":{\"phone\":\"+30691111111\"},\n  \"dialPlan\": {\n      \"verbs\":[\n      \n        {\n        \t \"type\": \"SAY\",\n           \"message\": {\n              \"language\": \"en-GB\",\n              \"gender\": \"female\",\n              \"text\": \"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement.\"\n            }\n        },\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n              \t\"gender\": \"female\",\n              \t\"text\": \"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree.\"\n            }\n        },\n        {\n  \t\t\t\t\t\"type\":\"PAUSE\",\n  \t\t\t\t\t\"duration\": 3\n\t\t\t\t},\n        {\n           \t\"type\": \"SAY\",\n           \t\"message\": {\n            \t  \"language\": \"en-GB\",\n            \t  \"gender\": \"female\",\n              \t\"text\": \"Thank you very much for participating in this valuable survey!\"\n            }\n        },\n        {\n           \"type\": \"COLLECT\",\n\t         \"eventUrl\": \"http://www.example.com\",\n           \"maxDigits\": 2,\n           \"submitOnHash\": false\n        }]\n  }\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"authorization": @"Bearer c2d9cf11-3576-4eb9-89c8-2781e5ca60a2",
                           @"content-type": @"application/json"};
NSDictionary *parameters = @{ @"from": @"Company",
                              @"to": @{ @"phone": @"+30691111111" },
                              @"dialPlan": @{ @"verbs": @[ @{ @"type": @"SAY", @"message": @{ @"language": @"en-GB", @"gender": @"female", @"text": @"You are invited to join this Voice Survey. We will use your information to improve our services for you and other customers. The survey will take just five minutes to complete. You will hear some statements about the service. Please indicate your level of agreement with each statement." } }, @{ @"type": @"SAY", @"message": @{ @"language": @"en-GB", @"gender": @"female", @"text": @"I am satisfied with the quality of products. Please press 1 for disagree, 2 for neutral, 3 for agree." } }, @{ @"type": @"PAUSE", @"duration": @3 }, @{ @"type": @"SAY", @"message": @{ @"language": @"en-GB", @"gender": @"female", @"text": @"I am satisfied with the reliability of the products. Please press 1 for disagree, 2 for neutral, 3 for agree." } }, @{ @"type": @"PAUSE", @"duration": @3 }, @{ @"type": @"SAY", @"message": @{ @"language": @"en-GB", @"gender": @"female", @"text": @"Thank you very much for participating in this valuable survey!" } }, @{ @"type": @"COLLECT", @"eventUrl": @"http://www.example.com", @"maxDigits": @2, @"submitOnHash": @"" } ] } };

NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/voice/conversation"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];

When the voice call is completed, Routee will immediately submit to the eventUrl the collected tones, the conversation id and the message id.

You will receive a payload as below:

{
  "from": "+231xxxxxxx",
  "to": "+140xxxxxxxx",
  "messageId": "string",
  "conversationTrackingId": "string",
  "collectedTones": "string"
}

Congratulations! You have just sent a Voice Survey.