Delayed Call Answer

    This example demonstrates how to wait for 10 seconds before accepting a call.

    Response

    <Response>
        <Wait length="10" />
        <Speak>Hello</Speak>
    </Response>
    

    Example Request

    1
    2
    3
    4
    5
    6
    
    from plivo import plivoxml
    
    response = (plivoxml.ResponseElement()
                .add(plivoxml.WaitElement(None)
                     .set_length(10)).add(plivoxml.SpeakElement('Hello')))
    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
    
    require 'rubygems'
    require 'plivo'
    
    include Plivo::XML
    include Plivo::Exceptions
    
    begin
      response = Response.new
    
      params = {
        length: '10'
      }
      response.addWait(params)
    
      speak_body = 'Hello'
      response.addSpeak(speak_body)
    
      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
    
    var plivo = require('plivo');
    
    var response = plivo.Response();
    
    var params = {
            'length': "10"
    };
    response.addWait(params);
    
    var speak_body = "Hello";
    response.addSpeak(speak_body);
    
    console.log(response.toXML());
    
    /*
    Sample Output
    <Response>
        <Wait length="10"/>
        <Speak>Hello</Speak>
    </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
    
    <?php
        require '../vendor/autoload.php';
        use Plivo\XML\Response;
    
        $response = new Response();
    
        $params = array(
            'length' => "10"
        );
        $response->addWait($params);
    
        $speak_body = "Hello";
        $response->addSpeak($speak_body);
    
        Header('Content-type: text/xml');
        echo($response->toXML());
    
        /*
        Sample Output
    
        <Response>
            <Wait length="10"/>
            <Speak>Hello</Speak>
        </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
    
    // Example for wait - delayed call answer
    package com.plivo.api.xml.samples.wait;
    
    import com.plivo.api.exceptions.PlivoXmlException;
    import com.plivo.api.xml.Response;
    import com.plivo.api.xml.Speak;
    import com.plivo.api.xml.Wait;
    
    
    class DelayedCallAnswer {
        public static void main(String[] args) throws PlivoXmlException {
            Response response = new Response()
                    .children(
    
    
                            new Wait()
                                    .length(10),
    
    
                            new Speak("Hello")
    
                    );
            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
    
    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.AddWait(new Dictionary<string, string>()
    			{
    				{"length", "10"}
    			});
    			resp.AddSpeak("Hello", 
                 new Dictionary<string, string>() { });
    			var output = resp.ToString();
    			Console.WriteLine(output);
    
    		}
    	}
    }
    
    
    
    //<Response>
    //  <Wait length = "10" />
    //  < Speak > Hello </ Speak >
    //</ Response >
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    // Example for wait - delayed answer
    package main
    
    import "github.com/plivo/plivo-go/xml"
    
    func main() {
    	response := xml.ResponseElement{
    		Contents: []interface{}{
    
    			new(xml.WaitElement).
    				SetLength(10),
    
    			new(xml.SpeakElement).
    				SetContents("Hello"),
    		},
    	}
    	print(response.String())
    }