When you make an outbound call and then connect that call to a different number using the Dial element, you can play a custom caller tone using the dialMusic attribute.
Plivo requests the dialMusic URL using the POST HTTP method for a valid Play, Speak, or Wait XML element.
To play a message on a call while it’s being connected, you should return the second XML example response.
<Response><Speak>Your call is being connected</Speak></Response>
Example Request
1
2
3
4
5
6
7
8
9
10
11
12
13
fromplivoimportplivoxmlresponse=plivoxml.ResponseElement()response.add(plivoxml.DialElement(dial_music='https://<yourdomain>.com/dial_music/').add(plivoxml.NumberElement('12025551111')))print(response.to_string())# XML to play the message
play_message_response=plivoxml.ResponseElement()play_message_response.add(plivoxml.SpeakElement('Your call is being connected'))print(play_message_response.to_string())
require'rubygems'require'plivo'includePlivo::XMLincludePlivo::Exceptionsbeginresponse=Response.newparams={'dialMusic'=>"https://<yourdomain>.com/dial_music/"}dial=response.addDial(params)first_number="12025551111"dial.addNumber(first_number)xml=PlivoXML.new(response)putsxml.to_xmlrescuePlivoXMLError=>eputs'Exception: '+e.messageendbeginresponse=Response.newspeak_body="Your call is being connected"response.addSpeak(speak_body)xml=PlivoXML.new(response)putsxml.to_xmlrescuePlivoXMLError=>eputs'Exception: '+e.messageend
varplivo=require('plivo');varresponse=plivo.Response();varparams={'dialMusic':"https://<yourdomain>.com/dial_music/"};vardial=response.addDial(params);varfirst_number="12025551111";dial.addNumber(first_number);console.log(response.toXML());/*
Sample Output
<Response>
<Dial dialMusic="https://<yourdomain>.com/dial_music/">
<Number>12025551111</Number>
</Dial>
</Response>
*//* Code to generate XML to be returned from url at dialMusic */varplivo=require('plivo');varresponse=plivo.Response();varspeak_body="Your call is being connected";response.addSpeak(speak_body);console.log(response.toXML());/*
Sample Output
<Response>
<Speak>Your call is being connected</Speak>
</Response>
*/
<?phprequire'../vendor/autoload.php';usePlivo\XML\Response;$response=newResponse();$params=array('dialMusic'=>"https://<yourdomain>.com/dial_music/");$dial=$response->addDial($params);$number="12025551111";$dial->addNumber($number);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Dial dialMusic="https://<yourdomain>.com/dial_music/">
<Number>12025551111</Number>
</Dial>
</Response>
*/?><?php/* XML to be returned by dialMusic */require'../vendor/autoload.php';usePlivo\XML\Response;$response=newResponse();$speak_body="Your call is being connected";$response->addSpeak($speak_body);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Speak>Your call is being connected</Speak>
</Response>
*/?>
// Example for dial - custom caller tonepackagecom.plivo.api.xml.samples.dial;importcom.plivo.api.exceptions.PlivoXmlException;importcom.plivo.api.xml.Dial;importcom.plivo.api.xml.Number;importcom.plivo.api.xml.Response;classCustomCallerTone{publicstaticvoidmain(String[]args)throwsPlivoXmlException{Responseresponse=newResponse().children(newDial().dialMusic("https://<yourdomain>.com/dial_music/").children(newNumber("12025551111")));System.out.println(response.toXmlString());}}
// Example for dial - caller tonepackagemainimport"github.com/plivo/plivo-go/v7/xml"funcmain(){response:=xml.ResponseElement{Contents:[]interface{}{new(xml.DialElement).SetDialMusic("https://<yourdomain>.com/dial_music/").SetContents([]interface{}{new(xml.NumberElement).SetContents("12025551111"),},),},}print(response.String())}
require'rubygems'require'plivo'includePlivoresponse=Response.new()params={'dialMusic'=>"https://www.foo.com/dial_music/"}dial=response.addDial(params)first_number="1111111111"dial.addNumber(first_number)putsresponse.to_xml()=begin
Sample Output
<Response>
<Dial dialMusic='https://www.foo.com/dial_music/'>
<Number>1111111111</Number>
</Dial>
</Response>
=end=begin
Code to generate XML to be returned from url at dialMusic
=endresponse=Response.new()speak_body="Your call is being connected"response.addSpeak(speak_body)putsresponse.to_xml()=begin
Sample Output
<Response>
<Speak>Your call is being connected</Speak>
</Response>
=end
varplivo=require('plivo');varresponse=plivo.Response();varparams={'dialMusic':"https://www.foo.com/dial_music/"};vardial=response.addDial(params);varfirst_number="1111111111";dial.addNumber(first_number);console.log(response.toXML());/*
Sample Output
<Response>
<Dial dialMusic="https://www.foo.com/dial_music/">
<Number>1111111111</Number>
</Dial>
</Response>
*//* Code to generate XML to be returned from url at dialMusic */varplivo=require('plivo');varresponse=plivo.Response();varspeak_body="Your call is being connected";response.addSpeak(speak_body);console.log(response.toXML());/*
Sample Output
<Response>
<Speak>Your call is being connected</Speak>
</Response>
*/
<?phprequire'../vendor/autoload.php';usePlivo\Response;$response=newResponse();$params=array('dialMusic'=>"https://www.foo.com/dial_music/");$dial=$response->addDial($params);$number="1111111111";$dial->addNumber($number);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Dial dialMusic="https://www.foo.com/dial_music/">
<Number>1111111111</Number>
</Dial>
</Response>
*/?><?php/* XML to be returned by dialMusic */require'../vendor/autoload.php';usePlivo\Response;$response=newResponse();$speak_body="Your call is being connected";$response->addSpeak($speak_body);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Speak>Your call is being connected</Speak>
</Response>
*/?>
// Example for dial - caller tonepackagemainimport"github.com/plivo/plivo-go/v7/xml"funcmain(){response:=xml.ResponseElement{Contents:[]interface{}{new(xml.DialElement).SetDialMusic("https://<yourdomain>.com/dial_music/").SetContents([]interface{}{new(xml.NumberElement).SetContents("12025551111"),},),},}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!