Record a complete call session
To record the entire call leg from start to end, set recordSession
attribute of the Record XML to “true” in your Answer XML. recordSession=”true” silently initiates a recording of the call in the background.
To record just the conversation between the A-Leg and the connected B-Leg (initiated using Dial XML), add a Record XML element with startOnDialAnswer
= “true” just before the Dial XML.
In either scenario, the call will be recorded until it is hung up or maxLength
recording duration is reached. It’s best to set maxLength to an adequately high value based on the maximum duration you expect your calls to go on for.
- If the
maxLength
value is not set, it will default to 60 seconds. - If
maxLength
is < 1 or an invalid integer, it will trigger an error “Record ‘maxLength’ must be a positive integer” and disconnect the call. - If
maxLength
is > 1 and valid integer, it will be set to the value.
Response
<Response>
<Record action="http://foo.com/get_recording/" startOnDialAnswer="true" redirect="false" maxLength="3600" />
<Dial>
<Number>15551234567</Number>
</Dial>
</Response>
Example Request
1
2
3
4
5
6
7
8
9
10
from plivo import plivoxml
response = plivoxml.ResponseElement()
response.add(
plivoxml.RecordElement(
action='http://foo.com/get_recording/',
start_on_dial_answer=True,
redirect=False))
response.add(plivoxml.DialElement().add(plivoxml.NumberElement('15551234567')))
print(response.to_string())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'rubygems'
require 'plivo'
include Plivo::XML
include Plivo::Exceptions
begin
response = Response.new
params = {
action: 'https://www.foo.com/get_recording/',
startOnDialAnswer: 'true',
redirect: 'false'
}
response.addRecord(params)
dial = response.addDial()
number = '1111111111'
dial.addNumber(number)
xml = PlivoXML.new(response)
puts xml.to_xml
rescue PlivoXMLError => e
puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var plivo = require('plivo');
var response = plivo.Response();
var params = {
'action': "https://www.foo.com/get_recording/",
'startOnDialAnswer': "true",
'redirect': "false"
};
response.addRecord(params);
var dial = response.addDial();
var number = "1111111111";
dial.addNumber(number);
console.log(response.toXML());
/*
Sample Output
<Response>
<Record action="https://www.foo.com/get_recording/" startOnDialAnswer="true" redirect="false"/>
<Dial>
<Number>1111111111</Number>
</Dial>
</Response>
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require '../vendor/autoload.php';
use Plivo\XML\Response;
$response = new Response();
$params = array(
'action' => "https://www.foo.com/get_recording/",
'startOnDialAnswer' => "true",
'redirect' => "false"
);
$response->addRecord($params);
$dial = $response->addDial();
$number = "1111111111";
$dial->addNumber($number);
Header('Content-type: text/xml');
echo($response->toXML());
/*
Sample Output
<Response>
<Record action="https://www.foo.com/get_recording/" startOnDialAnswer="true" redirect="false"/>
<Dial>
<Number>1111111111</Number>
</Dial>
</Response>
*/
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Example for record - record a complete call session
package com.plivo.api.xml.samples.record;
import com.plivo.api.exceptions.PlivoXmlException;
import com.plivo.api.xml.Dial;
import com.plivo.api.xml.Number;
import com.plivo.api.xml.Record;
import com.plivo.api.xml.Response;
class RecordACompleteCallSession {
public static void main(String[] args) throws PlivoXmlException {
Response response = new Response()
.children(
new Record("http://foo.com/get_recording/")
.redirect(false)
.startOnDialAnswer(true),
new Dial()
.children(
new Number("15551234567")
)
);
System.out.println(response.toXmlString());
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using Plivo.XML;
namespace Plivo
{
class MainClass
{
public static void Main(string[] args)
{
Plivo.XML.Response resp = new Plivo.XML.Response();
resp.AddRecord(new Dictionary<string, string>() {
{"action", "http://foo.com/get_recording/"},
{"startOnDialAnswer", "true"},
{"redirect", "false"}
});
Plivo.XML.Dial dial = new Plivo.XML.Dial(new
Dictionary<string, string>()
{ });
dial.AddNumber("15551234567",
new Dictionary<string, string>() { });
resp.Add(dial);
var output = resp.ToString();
Console.WriteLine(output);
}
}
}
//<Response>
// <Record action = "http://foo.com/get_recording/"
// startOnDialAnswer="true" redirect="false" />
// <Dial>
// <Number>15551234567</Number>
// </Dial>
//</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Example for record - record session
package main
import "github.com/plivo/plivo-go/xml"
func main() {
response := xml.ResponseElement{
Contents: []interface{}{
new(xml.RecordElement).
SetAction("http://foo.com/get_recording/").
SetRedirect(false).
SetStartOnDialAnswer(true),
new(xml.DialElement).
SetContents([]interface{}{
new(xml.NumberElement).
SetContents("15551234567"),
}),
},
}
print(response.String())
}
Rate this page
🥳 Thank you! It means a lot to us!
×
Help Us Improve
Thank you so much for rating the page, we would like to get your input for further improvements!
Subscribe to Updates
Thank you for your feedback!