Recording
Routee voice Api offers the ability to record an active call. This action can be achieved in 2 ways:
- The first one is to add the record option inside a ‘Dial’ verb
- The second one is to consume the Voice Api start recording an active voice call.
Example of a Dial Verb
{
"type": "DIAL",
"from":string,
"to": object,
"hangupDelay": int,
"maxDuration":int,
"callback": object,
"record": boolean,
"recordingFormat": string,
"recordingCallbackUrl": string,
"machineDetection":object
}
If the value record is true the call will be recorded. The recording Format can be mp3 or wav and the information of the recorded file will be transferred to the recordingCallbackUrl.
In order to do that with the voice API handling an active voice call, you will need the messageId of the voice call. In case of an inbound call, Routee provides the messageId at the Dialplan Url which the user set at the Number he/she has rent.
Now the user has all the information necessary, to consume the voice Api record an active call.
Example:
curl -X POST \
https://connect.routee.net/voice/conversation/09a7c9c6-b7e3-45a9-a918-6c947aae8c52/record \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: eb59c046-77b4-4d06-bd4e-15feca56856f' \
-H 'cache-control: no-cache' \
-d '{
"duration": 7,
"format": "MP3"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://connect.routee.net/voice/conversation/09a7c9c6-b7e3-45a9-a918-6c947aae8c52/record",
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 \"duration\": 7,\n \"format\": \"MP3\" \n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer {access_token}",
"Content-Type: application/json",
"Postman-Token: bed24efe-9944-41fa-b266-f50c30ca2cdc",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"duration\": 7,\n \"format\": \"MP3\" \n}");
Request request = new Request.Builder()
.url("https://connect.routee.net/voice/conversation/09a7c9c6-b7e3-45a9-a918-6c947aae8c52/record")
.post(body)
.addHeader("Authorization", "Bearer {access_token}")
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "44b3afb2-a307-400e-a618-5f606849b8bd")
.build();
Response response = client.newCall(request).execute();
var data = JSON.stringify({
"duration": 7,
"format": "MP3"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://connect.routee.net/voice/conversation/09a7c9c6-b7e3-45a9-a918-6c947aae8c52/record");
xhr.setRequestHeader("Authorization", "Bearer {access_token}");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("Postman-Token", "d9b2e3da-32d5-4705-aa3e-8dd3b2151b47");
xhr.send(data);
Query parameter | Description |
---|---|
messageId | The id of the voice call. |
Body parameter | Description |
---|---|
duration | The duration for each record that the user can perform. |
format | The record can have a format of a "MP3" or a "WAV" file. |
Updated over 5 years ago