When multiple calls are fired, the first person to answer gets connected and the rest of the calls are dropped. To make sure that the call is answered by a person and not by voice mail, use the confirmKey
and confirmSound
attributes.
The example XML here requires the call recipient to input the digit 5
after answering the call to connect.
Plivo requests the confirmSound
URL using the POST HTTP method for a valid Play, Speak, or a Wait XML element. To play a message asking the recipient to input a DTMF tone to connect the call, return the second XML example.
<Response>
<Dial confirmSound="https://<yourdomain>.com/confirm_sound/" confirmKey="5">
<Number>12025551111</Number>
<Number>12025552222</Number>
<Number>12025553333</Number>
</Dial>
</Response>
Â
Return the following XML to play a message.
<Response>
<Speak>Enter the digit 5 to connect the call</Speak>
</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from plivo import plivoxml
response = plivoxml.ResponseElement()
response.add(
plivoxml.DialElement(
confirm_key='5', confirm_sound='https://<yourdomain>.com/confirm_sound/').add(
plivoxml.NumberElement('12025551111')).add(
plivoxml.NumberElement('12025552222')).add(
plivoxml.NumberElement('12025553333')))
print(response.to_string())
# XML to play the message
play_message_response = plivoxml.ResponseElement()
play_message_response.add(
plivoxml.SpeakElement('Enter the digit 5 to connect the call'))
print(play_message_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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'rubygems'
require 'plivo'
include Plivo::XML
include Plivo::Exceptions
begin
response = Response.new
params = {
'confirmSound' => "https://<yourdomain>.com/confirm_sound/",
'confirmKey' => "5"
}
dial = response.addDial(params)
first_number = "12025551111"
dial.addNumber(first_number)
second_number = "12025552222"
dial.addNumber(second_number)
third_number = "12025553333"
dial.addNumber(third_number)
xml = PlivoXML.new(response)
puts xml.to_xml
rescue PlivoXMLError => e
puts 'Exception: ' + e.message
end
begin
response = Response.new
speak_body = "Enter the digit 5 to connect the call"
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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var plivo = require('plivo');
var response = plivo.Response();
var params = {
'confirmSound': "https://<yourdomain>.com/confirm_sound/",
'confirmKey': "5"
};
var dial = response.addDial(params);
var first_number = "12025551111";
dial.addNumber(first_number);
var second_number = "12025552222";
dial.addNumber(second_number);
var third_number = "12025553333";
dial.addNumber(third_number);
console.log(response.toXML());
/*
Sample Output
<Response>
<Dial confirmSound="https://<yourdomain>.com/confirm_sound/" confirmKey="5">
<Number>12025551111</Number>
<Number>12025552222</Number>
<Number>12025553333</Number>
</Dial>
</Response>
*/
/* Code to generate XML to be returned from url at confirmSound */
var plivo = require('plivo');
var response = plivo.Response();
var speak_body = "Enter the digit 5 to connect the call";
response.addSpeak(speak_body);
console.log(response.toXML());
/*
Sample Output
<Response>
<Speak>Enter the digit 5 to connect the call</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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require '../vendor/autoload.php';
use Plivo\XML\Response;
$response = new Response();
$params = array(
'confirmSound'=>"https://<yourdomain>.com/confirm_sound/",
'confirmKey' => "5"
);
$dial = $response->addDial($params);
$first_number = "12025551111";
$dial->addNumber($first_number);
$second_number = "12025552222";
$dial->addNumber($second_number);
$third_number = "12025553333";
$dial->addNumber($third_number);
Header('Content-type: text/xml');
echo($response->toXML());
/*
Sample Output
<Response>
<Dial confirmSound = "https://<yourdomain>.com/confirm_sound/" confirmKey="5">
<Number>12025551111</Number>
<Number>12025552222</Number>
<Number>12025553333</Number>
</Dial>
</Response>
*/
?>
<?php
/* XML to be returned by confirmSound */
require '../vendor/autoload.php';
use Plivo\XML\Response;
$response = new Response();
$speak_body = "Enter the digit 5 to connect the call";
$response->addSpeak($speak_body);
Header('Content-type: text/xml');
echo($response->toXML());
/*
Sample Output
<Response>
<Speak>Enter the digit 5 to connect the call</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
31
32
// Example for dial - confirm to answer call
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 ConfirmToAnswerCall {
public static void main(String[] args) throws PlivoXmlException {
Response response = new Response()
.children(
new Dial()
.confirmKey("5")
.confirmSound("https://<yourdomain>.com/confirm_sound/")
.children(
new Number("12025551111"),
new Number("12025552222"),
new Number("12025553333")
)
);
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://<yourdomain>.com/sound/"},
{"confirmKey", "3"}
});
dial.AddNumber("12025551111",
new Dictionary<string, string>() { });
dial.AddNumber("12025552222",
new Dictionary<string, string>() { });
dial.AddNumber("12025553333",
new Dictionary<string, string>() { });
resp.Add(dial);
var output = resp.ToString();
Console.WriteLine(output);
}
}
}
//<Response>
// <Dial confirmSound = "https://<yourdomain>.com/sound/"
// confirmKey="3">
// <Number>12025551111</Number>
// <Number>12025552222</Number>
// <Number>12025553333</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
// Example for dial - confirm to answer call
package main
import "github.com/plivo/plivo-go/v7/xml"
func main() {
response := xml.ResponseElement{
Contents: []interface{}{
new(xml.DialElement).
SetConfirmKey("5").
SetConfirmSound("https://<yourdomain>.com/confirm_sound/").
SetContents([]interface{}{
new(xml.NumberElement).
SetContents("12025551111"),
new(xml.NumberElement).
SetContents("12025552222"),
new(xml.NumberElement).
SetContents("12025553333"),
}),
},
}
print(response.String())
}