Send a Voice Messaging campaign

Routee's Voice Messaging API helps you to get in touch with your audience by sending Voice Messaging campaigns.

Either use your pre-recorded audio file (.wav format) or set a desired text message and leave our engine to transform Text to Speech.

The following example shows you how easy it is to send a Voice Messaging campaign using a pre-defined text.

Your Header should contain authorization and content type:

KEYVALUE
Authorization:Bearer {access_token}
Content-Type:application/json

Request body contains the voice message (text, language, gender), the sender (from), the recipient (to).

An example request is shown below:

curl -X POST 
-H "Authorization: Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59" 
-H "Content-Type: application/json" 
-H "Cache-Control: no-cache"  
-d '{
  "from":"+306977663000",
  "to":["+306977889000"],
  "message":{
    "text":"This is a test message, please ignore. Have a good day.",
    "language":"en-US",
    "gender":"female"
  },
  "campaignCallback": {
    "strategy": "OnChange",
    "url": "http://YOUR-CAMPAIGN-CALLBACK-URL.COM/campaign"
  },
  "callback": {
    "strategy": "OnCompletion",
    "url": "http://YOUR-CAMPAIGN-CALLBACK-URL.COM/message"
  }
}'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"from\":\"+306977663000\",\n  \"to\":[\"+306977663000\"],\n  \"message\":{\n    \"text\":\"This is a test message, please ignore. Have a good day.\",\n    \"language\":\"en-US\",\n    \"gender\":\"female\",\"campaignCallback\": { \"strategy\": \"OnCompletion\",\"url\": \"http://xxx.xxxxxxxx.xxx/campaign\" }, \"callback\": {\"strategy\": \"OnChange\", \"url\": \"http://xxx.xxxxxxxx.xxx/message\"}}");
Request request = new Request.Builder()
  .url("https://connect.routee.net/voice/campaign")
  .post(body)
  .addHeader("authorization", "Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var client = new RestClient("https://connect.routee.net/voice/campaign");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59");
request.AddParameter("application/json", "{\n  \"from\":\"+306977663000\",\n  \"to\":[\"+306977663000\"],\n  \"message\":{\n    \"text\":\"This is a test message, please ignore. Have a good day.\",\n    \"language\":\"en-US\",\n    \"gender\":\"female\"\n  },\n \"campaignCallback\": { \"strategy\": \"OnCompletion\",\"url\": \"http://xxx.xxxxxxxx.xxx/campaign\" }, \"callback\": {\"strategy\": \"OnChange\", \"url\": \"http://xxx.xxxxxxxx.xxx/message\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://connect.routee.net/voice/campaign",
  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\":\"+306977663000\",\n  \"to\":[\"+306977663000\"],\n  \"message\":{\n    \"text\":\"This is a test message, please ignore. Have a good day.\",\n    \"language\":\"en-US\",\n    \"gender\":\"female\"\n  },\n \"campaignCallback\": { \"strategy\": \"OnCompletion\",\"url\": \"http://xxx.xxxxxxxx.xxx/campaign\" }, \"callback\": {\"strategy\": \"OnChange\", \"url\": \"http://xxx.xxxxxxxx.xxx/message\"}}",
  CURLOPT_HTTPHEADER => array(
    "authorization: Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59",
    "cache-control: no-cache",
    "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\":\"+306977663000\",\n  \"to\":[\"+306977663000\"],\n  \"message\":{\n    \"text\":\"This is a test message, please ignore. Have a good day.\",\n    \"language\":\"en-US\",\n    \"gender\":\"female\"\n  },\n \"campaignCallback\": { \"strategy\": \"OnCompletion\",\"url\": \"http://xxx.xxxxxxxx.xxx/campaign\" }, \"callback\": {\"strategy\": \"OnChange\", \"url\": \"http://xxx.xxxxxxxx.xxx/message\"}}"

headers = {
    'authorization': "Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

conn.request("POST", "/voice/campaign", 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/campaign")

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 e6c6531c-4083-481e-b7a3-05be2ff41f59'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n  \"from\":\"+306977663000\",\n  \"to\":[\"+306977663000\"],\n  \"message\":{\n    \"text\":\"This is a test message, please ignore. Have a good day.\",\n    \"language\":\"en-US\",\n    \"gender\":\"female\"\n  },\n \"campaignCallback\": { \"strategy\": \"OnCompletion\",\"url\": \"http://xxx.xxxxxxxx.xxx/campaign\" }, \"callback\": {\"strategy\": \"OnChange\", \"url\": \"http://xxx.xxxxxxxx.xxx/message\"}}"

response = http.request(request)
puts response.read_body
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://connect.routee.net/voice/campaign",
  "method": "POST",
  "headers": {
    "authorization": "Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59",
    "content-type": "application/json",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": "{\n  \"from\":\"+306977663000\",\n  \"to\":[\"+306977663000\"],\n  \"message\":{\n    \"text\":\"This is a test message, please ignore. Have a good day.\",\n    \"language\":\"en-US\",\n    \"gender\":\"female\"\n  },\n \"campaignCallback\": { \"strategy\": \"OnCompletion\",\"url\": \"http://xxx.xxxxxxxx.xxx/campaign\" }, \"callback\": {\"strategy\": \"OnChange\", \"url\": \"http://xxx.xxxxxxxx.xxx/message\"}}" 
}

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

NSDictionary *headers = @{ @"authorization": @"Bearer e6c6531c-4083-481e-b7a3-05be2ff41f59",
                           @"content-type": @"application/json",
                           @"cache-control": @"no-cache" };
NSDictionary *parameters = @{ @"from": @"+306977663000",
                              @"to": @[ @"+306977663000" ],
                              @"message": @{ @"text": @"This is a test message, please ignore. Have a good day.", @"language": @"en-US", @"gender": @"female" },
                             @"campaignCallback": @{ @"strategy": @"OnCompletion", @"url": @"http://xxx.xxxxxxxx.xxx/campaign" },
                              @"callback": @{ @"strategy": @"OnChange", @"url": @"http://xxx.xxxxxxxx.xxx/message" } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://connect.routee.net/voice/campaign"]
                                                       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];

To get more information for sending Voice Campaigns check out our Resource Reference