DialStatus Reporting

This examples uses an action URL in the Dial XML. After completion of the call, Plivo will report back the status to this URL. You could control the flow of the call by returning a valid Plivo XML from the action URL and setting the redirect attribute as true.

In this example, Plivo will POST the status of the call to http://foo.com/dial_status/ and expects a valid XML since the redirect attribute is set to true.

Response

<Response>
    <Dial action="http://foo.com/dial_status/" method="POST" redirect="true">
        <Number>15671234567</Number>
    </Dial>
</Response>

Example Request

1
2
3
4
5
6
7
8
from plivo import plivoxml

response = plivoxml.ResponseElement()
response.add(
    plivoxml.DialElement(
        action='http://foo.com/dial_status/', method='POST', redirect=True)
    .add(plivoxml.NumberElement('15671234567')))
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
require 'rubygems'
require 'plivo'

include Plivo::XML
include Plivo::Exceptions

begin
  response = Response.new

  params = {
    'action' => "https://www.foo.com/dial_status/",
    'method' => "POST",
    'redirect' => "true"
  }

  dial = response.addDial(params)
  first_number = "1111111111"
  dial.addNumber(first_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
var plivo = require('plivo');

var response = plivo.Response();

var params = {
    'action': "https://www.foo.com/dial_status/",
    'method': "POST",
    'redirect': "true"
};
var dial = response.addDial(params);

var first_number = "1111111111";
dial.addNumber(first_number);

console.log(response.toXML());

/*
Sample Output
<Response>
    <Dial action="https://www.foo.com/dial_status/" method="POST" redirect="true">
        <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
<?php
    require '../vendor/autoload.php';
    use Plivo\XML\Response;

    $response = new Response();

    $params = array(
        'action' => "https://www.foo.com/dial_status/",
        'method' => "POST",
        'redirect' => "true"
    );

    $dial = $response->addDial($params);
    $number = "1111111111";
    $dial->addNumber($number);

    Header('Content-type: text/xml');
    echo($response->toXML());

    /*
    Sample Output

    <Response>
        <Dial action="https://www.foo.com/dial_status/" method="POST" redirect="true">
            <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 dial - dial status reporting
package com.plivo.api.xml.samples.dial;

import com.plivo.api.exceptions.PlivoXmlException;
import com.plivo.api.xml.Dial;
import com.plivo.api.xml.Number;
import com.plivo.api.xml.Response;


class DialStatusReporting {
    public static void main(String[] args) throws PlivoXmlException {
        Response response = new Response()
                .children(


                        new Dial()
                                .action("http://foo.com/dial status/")
                                .method("POST")
                                .redirect(true)
                                .children(


                                        new Number("15671234567")
                                )

                );
        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
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();
			Plivo.XML.Dial dial = new Plivo.XML.Dial(new
				Dictionary<string, string>() {
				{"action", "http://foo.com/dial_status/"},
				{"method", "POST"},
				{"redirect", "true"}
			});

			dial.AddNumber("15551234567",
				new Dictionary<string, string>() { });
			resp.Add(dial);

			var output = resp.ToString();
			Console.WriteLine(output);

		}
	}
}



//<Response>
//  <Dial action = "http://foo.com/dial_status/" 
//    method="POST" redirect="true">
//    <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
// Example for dial - dial status
package main

import "github.com/plivo/plivo-go/xml"

func main() {
	response := xml.ResponseElement{
		Contents: []interface{}{

			new(xml.DialElement).
				SetAction("http://foo.com/dial status/").
				SetMethod("POST").
				SetRedirect(true).
				SetContents([]interface{}{
					new(xml.NumberElement).
						SetContents("15671234567"),
				}),
		},
	}
	print(response.String())
}