How to record a bridged call

If you want to record a bridged call eg for security or quality assurance reasons, you are able to do so by using Routee's conversation API.

In order to do so, you have to set to "true" the "record" parameter inside the DIAL verb of your dialplan. You can use it either for inbound or for outbound conversations.

In this example, you will see how to record an outbound conversation and download the recorded file.

Your Header should contain authorization and content type:

KEYVALUE
AuthorizationBearer {access_token}
Content-Typeapplication/json

The example request is shown below:

{  
   "from":"routee",
   "to":{  
      "phone":"+1302xxxxxxx"
   },
   "dialPlan":{  
      "verbs":[  
         {  
            "type":"SAY",
            "message":{  
               "language":"en-US",
               "gender":"male",
               "text":"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons"
            }
         },
         {  
            "type":"DIAL",
            "from":"1302xxxxxx1",
            "to":{  
               "phone":"+1301xxxxxx2"
            },
            "record":true,
            "recordingFormat":"WAV"
         }
      ]
   }
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{  \n   \"from\":\"routee\",\n   \"to\":{  \n      \"phone\":\"+1302xxxxxxx\"\n   },\n   \"dialPlan\":{  \n      \"verbs\":[  \n         {  \n            \"type\":\"SAY\",\n            \"message\":{  \n               \"language\":\"en-US\",\n               \"gender\":\"male\",\n               \"text\":\"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons\"\n            }\n         },\n         {  \n            \"type\":\"DIAL\",\n            \"from\":\"1302xxxxxxx\",\n            \"to\":{  \n               \"phone\":\"+1301xxxxxxx\"\n            },\n            \"record\":true,\n            \"recordingFormat\":\"WAV\"\n         }\n      ]\n   }\n}");
Request request = new Request.Builder()
  .url("https://connect.routee.net/voice/conversation")
  .post(body)
  .addHeader("Authorization", "Bearer 55a3c994-9543-41e6-a90f-c0b6fe11d9be")
  .addHeader("Content-Type", "application/json")
  .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 55a3c994-9543-41e6-a90f-c0b6fe11d9be");
request.AddParameter("undefined", "{  \n   \"from\":\"routee\",\n   \"to\":{  \n      \"phone\":\"+1302xxxxxxx\"\n   },\n   \"dialPlan\":{  \n      \"verbs\":[  \n         {  \n            \"type\":\"SAY\",\n            \"message\":{  \n               \"language\":\"en-US\",\n               \"gender\":\"male\",\n               \"text\":\"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons\"\n            }\n         },\n         {  \n            \"type\":\"DIAL\",\n            \"from\":\"1302xxxxxxx\",\n            \"to\":{  \n               \"phone\":\"+1301xxxxxxx\"\n            },\n            \"record\":true,\n            \"recordingFormat\":\"WAV\"\n         }\n      ]\n   }\n}", 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\":\"routee\",\n   \"to\":{  \n      \"phone\":\"+1302xxxxxxx\"\n   },\n   \"dialPlan\":{  \n      \"verbs\":[  \n         {  \n            \"type\":\"SAY\",\n            \"message\":{  \n               \"language\":\"en-US\",\n               \"gender\":\"male\",\n               \"text\":\"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons\"\n            }\n         },\n         {  \n            \"type\":\"DIAL\",\n            \"from\":\"1302xxxxxxx\",\n            \"to\":{  \n               \"phone\":\"+1301xxxxxxx\"\n            },\n            \"record\":true,\n            \"recordingFormat\":\"WAV\"\n         }\n      ]\n   }\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer 55a3c994-9543-41e6-a90f-c0b6fe11d9be",
    "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.HTTPConnection("connect.routee.net")

payload = "{  \n   \"from\":\"routee\",\n   \"to\":{  \n      \"phone\":\"+1302xxxxxxx\"\n   },\n   \"dialPlan\":{  \n      \"verbs\":[  \n         {  \n            \"type\":\"SAY\",\n            \"message\":{  \n               \"language\":\"en-US\",\n               \"gender\":\"male\",\n               \"text\":\"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons\"\n            }\n         },\n         {  \n            \"type\":\"DIAL\",\n            \"from\":\"1302xxxxxxx\",\n            \"to\":{  \n               \"phone\":\"+1301xxxxxxx\"\n            },\n            \"record\":true,\n            \"recordingFormat\":\"WAV\"\n         }\n      ]\n   }\n}"

headers = {
    'Authorization': "Bearer 55a3c994-9543-41e6-a90f-c0b6fe11d9be",
    '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)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer 55a3c994-9543-41e6-a90f-c0b6fe11d9be'
request["Content-Type"] = 'application/json'
request.body = "{  \n   \"from\":\"routee\",\n   \"to\":{  \n      \"phone\":\"+1302xxxxxxx\"\n   },\n   \"dialPlan\":{  \n      \"verbs\":[  \n         {  \n            \"type\":\"SAY\",\n            \"message\":{  \n               \"language\":\"en-US\",\n               \"gender\":\"male\",\n               \"text\":\"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons\"\n            }\n         },\n         {  \n            \"type\":\"DIAL\",\n            \"from\":\"1302xxxxxxx\",\n            \"to\":{  \n               \"phone\":\"+1301xxxxxxx\"\n            },\n            \"record\":true,\n            \"recordingFormat\":\"WAV\"\n         }\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 55a3c994-9543-41e6-a90f-c0b6fe11d9be",
    "Content-Type": "application/json"
  },
  "processData": false,
  "data": "{  \n   \"from\":\"routee\",\n   \"to\":{  \n      \"phone\":\"+1302xxxxxxx\"\n   },\n   \"dialPlan\":{  \n      \"verbs\":[  \n         {  \n            \"type\":\"SAY\",\n            \"message\":{  \n               \"language\":\"en-US\",\n               \"gender\":\"male\",\n               \"text\":\"We will connect you shortly to customer support. Please hang on to your phone. We want to inform you that this call is recorded for security reasons\"\n            }\n         },\n         {  \n            \"type\":\"DIAL\",\n            \"from\":\"1302xxxxxxx\",\n            \"to\":{  \n               \"phone\":\"+1301xxxxxxx\"\n            },\n            \"record\":true,\n            \"recordingFormat\":\"WAV\"\n         }\n      ]\n   }\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

The recipient of the conversation (+1302xxxxxx1) will receive a call. He will hear the informative message and then he will be connected to the recipient inside the DIAL verb (+1301xxxxxx2). The whole duration of the call will be recorded, in wav format. If recording Format is not set, the default will be mp3.