Record a complete call session

You can record an entire call session on a Dial using the below XML response.

Response

<Response>
    <Record action="http://foo.com/get_recording/" startOnDialAnswer="true" redirect="false" />
    <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())
}