Simultaneous dialing

    This example uses three User and Number elements to dial two SIP endpoints and a phone number at the same time. The first of these calls to answer will be connected to the caller, and the rest of the connection attempts will be canceled.

    Response

    <Response>
        <Dial>
          <User>sip:alice1234@phone.plivo.com</User>
          <Number>15671234567</Number>
          <User>sip:john1234@phone.plivo.com</User>
        </Dial>
    </Response>
    

    Example Request

    1
    2
    3
    4
    5
    6
    7
    8
    
    from plivo import plivoxml
    
    response = plivoxml.ResponseElement()
    response.add(plivoxml.DialElement().add(
        plivoxml.UserElement('sip:alice1234@phone.plivo.com')).add(
            plivoxml.NumberElement('15671234567')).add(
                plivoxml.UserElement('sip:john1234@phone.plivo.com')))
    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
    
      dial = response.addDial()
      first_user = "sip:alice1234@phone.plivo.com"
      dial.addUser(first_user)
    
      number = "1111111111"
      dial.addNumber(number)
    
      second_user = "sip:john1234@phone.plivo.com"
      dial.addUser(second_user)
    
      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
    27
    
    var plivo = require('plivo');
    
    var response = plivo.Response();
    
    var dial = response.addDial();
    
    var first_user = "sip:alice1234@phone.plivo.com";
    dial.addUser(first_user);
    
    var number = "1111111111";
    dial.addNumber(number);
    
    var second_user = "sip:john1234@phone.plivo.com";
    dial.addUser(second_user);
    
    console.log(response.toXML());
    
    /*
    Sample Output
    <Response>
        <Dial>
            <User>sip:alice1234@phone.plivo.com</User>
            <Number>1111111111</Number>
            <User>sip:john1234@phone.plivo.com</User>
        </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
    
    <?php
        require '../vendor/autoload.php';
        use Plivo\XML\Response;
    
        $response = new Response();
    
        $dial = $response->addDial();
        $first_user = "sip:alice1234@phone.plivo.com";
        $dial->addUser($first_user);
    
        $number = "1111111111";
        $dial->addNumber($number);
    
        $second_user = "sip:john1234@phone.plivo.com";
        $dial->addUser($second_user);
    
        Header('Content-type: text/xml');
        echo($response->toXML());
    
        /*
        Sample Output
    
        <Response>
            <Dial>
                <User>sip:alice1234@phone.plivo.com</User>
                <Number>1111111111</Number>
                <User>sip:john1234@phone.plivo.com</User>
            </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
    33
    
    // Example for dial - simultaneous dialing
    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;
    import com.plivo.api.xml.User;
    
    
    class SimultaneousDialing {
        public static void main(String[] args) throws PlivoXmlException {
            Response response = new Response()
                    .children(
    
    
                            new Dial()
                                    .action("https://foo.com/dial action/")
                                    .timeout(20)
                                    .children(
                                            new User("sip:alice1234@phone.plivo.com"),
    
    
                                            new Number("18217654321"),
    
    
                                            new User("sip:john1234@phone.plivo.com")
                                    )
    
                    );
            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
    42
    
    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>() {
    				{"confirmSound", "https://foo.com/sound/"},
    				{"confirmKey", "3"}
    			});
    
    			dial.AddUser("sip:alice1234@phone.plivo.com",
    				new Dictionary<string, string>() { });
    			dial.AddNumber("18217654321",
    				new Dictionary<string, string>() { });
    			dial.AddUser("sip:john1234@phone.plivo.com",
    				new Dictionary<string, string>() { });
    			resp.Add(dial);
    
    			var output = resp.ToString();
    			Console.WriteLine(output);
    
    		}
    	}
    }
    
    
    
    //<Response>
    //  <Dial confirmSound = "https://foo.com/sound/" 
    //      confirmKey="3">
    //    <User>sip:alice1234 @phone.plivo.com</User>
    //    <Number>18217654321</Number>
    //    <User>sip:john1234 @phone.plivo.com</User>
    //  </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
    
    // Example for dial - simultaneous dialing
    package main
    
    import "github.com/plivo/plivo-go/xml"
    
    func main() {
    	response := xml.ResponseElement{
    		Contents: []interface{}{
    
    			new(xml.DialElement).
    				SetAction("https://foo.com/dial action/").
    				SetTimeout(20).
    				SetContents([]interface{}{
    					new(xml.UserElement).
    						SetContents("sip:alice1234@phone.plivo.com"),
    
    					new(xml.NumberElement).
    						SetContents("18217654321"),
    
    					new(xml.UserElement).
    						SetContents("sip:john1234@phone.plivo.com"),
    				}),
    		},
    	}
    	print(response.String())
    }