Machine Detection
The silence
parameter is often used in conjunction with the machine_detection
feature of the Call API to enable your XML to detect if a call is answered by voice mail. When silence
is set to true
, as soon as the voice mail finishes speaking, and there is a silence for minSilence
milliseconds, the next element in the XML is processed, without waiting for the whole period of length
seconds to pass.
Response
<Response>
<Wait length="10" silence="true" minSilence="3000" />
<Speak>Hello, welcome to the Jungle!</Speak>
</Response>
Example Request
1
2
3
4
5
6
from plivo import plivoxml
response = (plivoxml.ResponseElement().add(
plivoxml.WaitElement(None).set_length(10).set_min_silence(3000)
.set_silence(True)).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
23
24
require 'rubygems'
require 'plivo'
include Plivo::XML
include Plivo::Exceptions
begin
response = Response.new
params = {
length: '10',
silence: true,
min_silence: '3000'
}
response.addWait(params)
speak_body = 'Hello, welcome to the Jungle!'
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
var plivo = require('plivo');
var response = plivo.Response();
var params = {
'length': "10",
'silence': "true",
'minSilence': "3000"
};
response.addWait(params);
var speak_body = "Hello, welcome to the Jungle!";
response.addSpeak(speak_body);
console.log(response.toXML());
/*
Sample Output
<Response>
<Wait length="10" silence="true" minSilence="3000"/>
<Speak>Hello, welcome to the Jungle!</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
<?php
require '../vendor/autoload.php';
use Plivo\XML\Response;
$response = new Response();
$params = array(
'length' => "10",
'silence' => "true",
'minSilence' => "3000"
);
$response->addWait($params);
$speak_body = "Hello, welcome to the Jungle!";
$response->addSpeak($speak_body);
Header('Content-type: text/xml');
echo($response->toXML());
/*
Sample Output
<Response>
<Wait length="10" silence="true" minSilence="3000"/>
<Speak>Hello, welcome to the Jungle!</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
// Example for wait - machine detection
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 MachineDetection {
public static void main(String[] args) throws PlivoXmlException {
Response response = new Response()
.children(
new Wait()
.length(10)
.minSilence(3000)
.silence(true),
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
31
32
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"},
{"silence", "true"},
{"minSilence", "3000"}
});
resp.AddSpeak("Hello, welcome to the Jungle.",
new Dictionary<string, string>() { });
var output = resp.ToString();
Console.WriteLine(output);
}
}
}
//<Response>
// <Wait length = "10" silence="true" minSilence="3000" />
// <Speak>Hello, welcome to the Jungle.</Speak>
//</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Example for wait - machine detection
package main
import "github.com/plivo/plivo-go/xml"
func main() {
response := xml.ResponseElement{
Contents: []interface{}{
new(xml.WaitElement).
SetLength(10).
SetMinSilence(3000).
SetSilence(true),
new(xml.SpeakElement).
SetContents("Hello"),
},
}
print(response.String())
}
Rate this page
🥳 Thank you! It means a lot to us!
×
Help Us Improve
Thank you so much for rating the page, we would like to get your input for further improvements!
Subscribe to Updates
Thank you for your feedback!