In this example, we have a Redirect element after a Speak element. When the Speak element finishes, the Redirect element executes, and Plivo processes the call based on the XML returned from the Redirect element.
Response
<Response><Speak>Please wait while you call is being transferred.</Speak><Redirect>https://<yourdomain>.com/redirect/</Redirect></Response>
To connect the incoming call to a different number, you should return the section example’s XML from the Redirect URL.
fromplivoimportplivoxmlresponse=plivoxml.ResponseElement()response.add(plivoxml.SpeakElement('Your call is being transferred.'))response.add(plivoxml.RedirectElement('https://<yourdomain>.com/redirect/'))print(response.to_string())
require'rubygems'require'plivo'includePlivo::XMLincludePlivo::Exceptionsbeginresponse=Response.newspeak_body='Your call is being transferred.'response.addSpeak(speak_body)redirect_url='https://<yourdomain>.com/redirect/'response.addRedirect(redirect_url);xml=PlivoXML.new(response)putsxml.to_xmlrescuePlivoXMLError=>eputs'Exception: '+e.messageend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
varplivo=require('plivo');varresponse=plivo.Response();varspeak_body="Your call is being transferred.";response.addSpeak(speak_body);varredirect_url="https://<yourdomain>.com/redirect/";response.addRedirect(redirect_url);console.log(response.toXML());/*
Sample Output
<Response>
<Speak>Your call is being transferred.</Speak>
<Redirect>https://<yourdomain>.com/redirect/</Redirect>
</Response>
*/
<?phprequire'../vendor/autoload.php';usePlivo\XML\Response;$response=newResponse();$speak_body="Your call is being transferred.";$response->addSpeak($speak_body);$redirect_url="https://<yourdomain>.com/redirect/";$response->addRedirect($redirect_url);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Speak>Your call is being transferred.</Speak>
<Redirect>https://<yourdomain>.com/redirect/</Redirect>
</Response>
*/?>
// Example for xml - transfer a callpackagecom.plivo.api.xml.samples.xml;importcom.plivo.api.exceptions.PlivoXmlException;importcom.plivo.api.xml.Redirect;importcom.plivo.api.xml.Response;importcom.plivo.api.xml.Speak;classTransferACall{publicstaticvoidmain(String[]args)throwsPlivoXmlException{Responseresponse=newResponse().children(newSpeak("Your call is being transferred."),newRedirect("https://<yourdomain>.com/redirect/"));System.out.println(response.toXmlString());}}
usingSystem;usingSystem.Collections.Generic;usingPlivo.XML;namespacePlivo{classMainClass{publicstaticvoidMain(string[]args){Plivo.XML.Responseresp=newPlivo.XML.Response();resp.AddSpeak("Your call is being transferred.",newDictionary<string,string>(){});resp.AddRedirect("https://<yourdomain>.com/redirect/",newDictionary<string,string>(){});varoutput=resp.ToString();Console.WriteLine(output);}}}//<Response>// <Speak>You call is being transferred.</Speak>// <Redirect>https://<yourdomain>.com/redirect/</Redirect>//</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for xml - transfer callpackagemainimport"github.com/plivo/plivo-go/v7/xml"funcmain(){response:=xml.ResponseElement{Contents:[]interface{}{new(xml.SpeakElement).AddSpeak("Your call is being transferred."),new(xml.RedirectElement).SetContents("https://<yourdomain>.com/redirect/"),},}print(response.String())}
fromflaskimportFlask,Response,requestimportplivoxmlapp=Flask(__name__)@app.route('/transfer_call/',methods=['GET','POST'])deftransfer_call():response=plivoxml.Response()response.addSpeak("Your call is being transferred.")response.addRedirect("https://foo.com/redirect")returnResponse(str(response),mimetype='text/xml')if__name__=="__main__":app.run(host='0.0.0.0',debug=True)# Sample Conference XML
# <Response>
# <Speak>Your call is being transferred.</Speak>
# <Redirect>https://foo.com/redirect</Redirect>
# </Response>
require'rubygems'require'plivo'includePlivoresponse=Response.new()speak_body="Please wait while you call is being transferred."response.addSpeak(speak_body)redirect_url="https://www.foo.com/redirect/"response.addRedirect(redirect_url);putsresponse.to_xml()=begin
Sample Output
<Response>
<Speak>Please wait while you call is being transferred.</Speak>
<Redirect>https://www.foo.com/redirect/</Redirect>
</Response>
=end=begin
Code to generate XML to be returned from url at redirect_url
=endresponse=Response.new()params={'dialMusic'=>"real"}dial=response.addDial(params)number="1111111111"dial.addNumber(number)putsresponse.to_xml()=begin
Sample Output
<Response>
<Dial dialMusic='real'>
<Number>1111111111</Number>
</Dial>
</Response>
=end
varplivo=require('plivo');varresponse=plivo.Response();varspeak_body="Please wait while you call is being transferred.";response.addSpeak(speak_body);varredirect_url="https://www.foo.com/redirect/";response.addRedirect(redirect_url);console.log(response.toXML());/*
Sample Output
<Response>
<Speak>Please wait while you call is being transferred.</Speak>
<Redirect>https://www.foo.com/redirect/</Redirect>
</Response>
*//* Code to generate XML to be returned from url at
redirect_url */varplivo=require('plivo');varresponse=plivo.Response();varparams={'dialMusic':"real"};vardial=response.addDial(params);varnumber="1111111111";dial.addNumber(number);console.log(response.toXML());/*
Sample Output
<Response>
<Dial dialMusic="real">
<Number>1111111111</Number>
</Dial>
</Response>
*/
<?phprequire'../vendor/autoload.php';usePlivo\Response;$response=newResponse();$speak_body="Please wait while you call is being transferred.";$response->addSpeak($speak_body);$redirect_url="https://www.foo.com/redirect/";$response->addRedirect($redirect_url);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Speak>Please wait while you call is being transferred.</Speak>
<Redirect>https://www.foo.com/redirect/</Redirect>
</Response>
*/?><?php/* XML to be returned by the redirect URL */require'../vendor/autoload.php';usePlivo\Response;$response=newResponse();$params=array('dialMusic'=>"real");$dial=$response->addDial($params);$number="1111111111";$dial->addNumber($number);Header('Content-type: text/xml');echo($response->toXML());/*
Sample Output
<Response>
<Dial dialMusic="real">
<Number>1111111111</Number>
</Dial>
</Response>
*/?>
importjava.io.IOException;importcom.plivo.helper.exception.PlivoException;importcom.plivo.helper.xml.elements.Speak;importcom.plivo.helper.xml.elements.Redirect;importcom.plivo.helper.xml.elements.PlivoResponse;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.eclipse.jetty.server.Server;importorg.eclipse.jetty.servlet.ServletContextHandler;importorg.eclipse.jetty.servlet.ServletHolder;publicclasstransferCallextendsHttpServlet{privatestaticfinallongserialVersionUID=1L;@OverrideprotectedvoiddoGet(HttpServletRequestreq,HttpServletResponseresp)throwsServletException,IOException{PlivoResponseresponse=newPlivoResponse();Speakspeak=newSpeak("Please wait, your call is being transferred.");Redirectredirect=newRedirect("https://foo.com/redirect/");try{response.append(speak);response.append(redirect);System.out.println(response.toXML());resp.addHeader("Content-Type","text/xml");resp.getWriter().print(response.toXML());;}catch(PlivoExceptione){e.printStackTrace();}}publicstaticvoidmain(String[]args)throwsException{Stringport=System.getenv("PORT");if(port==null)port="8000";Serverserver=newServer(Integer.valueOf(port));ServletContextHandlercontext=newServletContextHandler(ServletContextHandler.SESSIONS);context.setContextPath("/");server.setHandler(context);context.addServlet(newServletHolder(newtransferCall()),"/transfer_call");server.start();server.join();}}/*
Sample Output
<Response>
<Speak>
Please wait while you call is being transferred.
</Speak>
<Redirect>https://foo.com/redirect/</Redirect>
</Response>
*/
usingSystem;usingSystem.Collections.Generic;usingPlivo.XML;namespacePlivo{classMainClass{publicstaticvoidMain(string[]args){Plivo.XML.Responseresp=newPlivo.XML.Response();resp.AddSpeak("Your call is being transferred.",newDictionary<string,string>(){});resp.AddRedirect("https://foo.com/redirect/",newDictionary<string,string>(){});varoutput=resp.ToString();Console.WriteLine(output);}}}//<Response>// <Speak>You call is being transferred.</Speak>// <Redirect>https://foo.com/redirect/</Redirect>//</Response>
// Example for xml - transfer callpackagemainimport"github.com/plivo/plivo-go/v7/xml"funcmain(){response:=xml.ResponseElement{Contents:[]interface{}{new(xml.SpeakElement).AddSpeak("Your call is being transferred."),new(xml.RedirectElement).SetContents("https://<yourdomain>.com/redirect/"),},}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!