Latest Legacy

Basic wait

This first example demonstrates how to wait for seven seconds between two lines of speech.

Response

<Response>
    <Speak>I will wait for seven seconds starting now.</Speak>
    <Wait length="7" />
    <Speak>I just waited seven seconds.</Speak>
</Response>

Example Request

1
2
3
4
5
6
7
from plivo import plivoxml

response = (plivoxml.ResponseElement()
            .add(plivoxml.SpeakElement('I will wait 6 seconds starting now.'))
            .add(plivoxml.WaitElement(None).set_length(6))
            .add(plivoxml.SpeakElement('I just waited 6 seconds.')))
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
require 'rubygems'
require 'plivo'

include Plivo::XML
include Plivo::Exceptions

begin
  response = Response.new

  first_speak_body = 'I will wait 7 seconds starting now!'
  response.addSpeak(first_speak_body)

  params = {
    length: '7'
  }
  response.addWait(params)

  second_speak_body = 'I just waited 7 seconds.'
  response.addSpeak(second_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
22
23
24
25
var plivo = require('plivo');

var response = plivo.Response();

var first_speak_body = "I will wait 7 seconds starting now!";
response.addSpeak(first_speak_body);

var params = {
        'length': "7"
};
response.addWait(params);

var second_speak_body = "I just waited 7 seconds.";
response.addSpeak(second_speak_body);

console.log(response.toXML());

/*
Sample Output
<Response>
    <Speak>I will wait 7 seconds starting now!</Speak>
    <Wait length="7"/>
    <Speak>I just waited 7 seconds.</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
27
28
29
30
<?php
    require '../vendor/autoload.php';
    use Plivo\XML\Response;

    $response = new Response();

    $first_speak_body = "I will wait 7 seconds starting now!";
    $response->addSpeak($first_speak_body);

    $params = array(
        'length' => "7"
    );
    $response->addWait($params);

    $second_speak_body = "I just waited 7 seconds.";
    $response->addSpeak($second_speak_body);

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

    /*
    Sample Output

    <Response>
        <Speak>I will wait 7 seconds starting now!</Speak>
        <Wait length="7"/>
        <Speak>I just waited 7 seconds.</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
27
28
// Example for wait - basic wait
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 BasicWait {
    public static void main(String[] args) throws PlivoXmlException {
        Response response = new Response()
                .children(


                        new Speak("I will wait 6 seconds starting now."),


                        new Wait()
                                .length(6),


                        new Speak("I just waited 6 seconds.")

                );
        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
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.AddSpeak("I will wait 7 seconds starting now!", 
             new Dictionary<string, string>() { });
			resp.AddWait(new Dictionary<string, string>()
			{
				{"length", "7"}
			});
			resp.AddSpeak("I just waited 7 seconds.", 
             new Dictionary<string, string>() { });
			var output = resp.ToString();
			Console.WriteLine(output);

		}
	}
}



//<Response>
//  <Speak>I will wait 7 seconds starting now!</Speak>
//  <Wait length = "7" />
//  < Speak > I just waited 7 seconds.</Speak>
//</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Example for wait - basic wait
package main

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

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

			new(xml.SpeakElement).
				AddSpeak("I will wait 6 seconds starting now."),

			new(xml.WaitElement).
				SetLength(6),

			new(xml.SpeakElement).
				AddSpeak("I just waited 6 seconds."),
		},
	}
	print(response.String())
}