Twilio IVR,TwiML;如何设置按键以拨打特定号码?
我正试图在Twilio网站上用TwiML编写一个IVR。理想情况下,我希望发生的是:Twilio IVR,TwiML;如何设置按键以拨打特定号码?,twilio,twilio-twiml,Twilio,Twilio Twiml,我正试图在Twilio网站上用TwiML编写一个IVR。理想情况下,我希望发生的是: 按“1”可拨打我设置的号码 按“2”键可拨打我设置的号码 按“3”键将我带到一个目录。嵌套在数字“3”中,它们会再次显示多个选项,每个选项都会拨一个特定的号码 我想我应该在某个地方使用action,但我不知道如何设置拨号的“if”条件。我在编码方面的知识充其量是极其初级的,但这里是我迄今为止所建立的 <?xml version="1.0" encoding="UTF-8"?> <Respo
- 按“1”可拨打我设置的号码
- 按“2”键可拨打我设置的号码
- 按“3”键将我带到一个目录。嵌套在数字“3”中,它们会再次显示多个选项,每个选项都会拨一个特定的号码
action
,但我不知道如何设置拨号的“if”条件。我在编码方面的知识充其量是极其初级的,但这里是我迄今为止所建立的
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="2"/>
<Say voice="alice" language="en-gb">Thank you for calling our company, your number one source for commercial real estate listings.</Say>
<Gather numDigits="1">
<Say voice="alice" language="en-gb">Press 1 for Sales to Sign Up and Stand Out!</Say>
<Say voice="alice" language="en-gb">Press 2 for Support!</Say>
<Say voice="alice" language="en-gb">Press 3 for our company directory!</Say>
</Gather>
</Response>
感谢您致电我们公司,我们是您的第一大商业房地产房源。
按1键销售人员注册并脱颖而出!
按2获得支持!
按3键进入我们的公司目录!
你是对的-你必须对其采取行动。此操作URL将获得用户按下的“数字”,然后您可以采取适当的操作
请参阅下面的示例(action=“/abcxyzDemoIvr”)
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="2"/>
<Say voice="alice" language="en-gb">Thank you for calling our company, your number one source for commercial real estate listings.</Say>
<Gather numDigits="1" action="<urlHere>/abcxyzDemoIvr">
<Say voice="alice" language="en-gb">Press 1 for Sales to Sign Up and Stand Out!</Say>
<Say voice="alice" language="en-gb">Press 2 for Support!</Say>
<Say voice="alice" language="en-gb">Press 3 for our company directory!</Say>
</Gather>
</Response>
app.post('/abcxyzDemoIvr',
function(i_Req,o_Res)
{
var ivrTwilRes = new twilio.TwimlResponse();
var iGathered=i_Req.body.Digits ;
if ( iGathered == 1)
{
ivrTwilRes.say("Action for Sales to Sign Up and Stand Out!");
ivrTwilRes.redirect( { method : 'GET' } , "/abcxyzDemoIvr_salesSignupAndStandOut" );
/*do your stuff here */
}
else if ( iGathered == 2 )
{
ivrTwilRes.say("Action for Support");
ivrTwilRes.redirect( { method : 'GET' } , "/abcxyzDemoIvr_support" );
/*do your stuff here */
}
else if ( iGathered == 3 )
{
ivrTwilRes.say("Action for CompanyDirectory");
ivrTwilRes.redirect( { method : 'GET' } , "/abcxyzDemoIvr_companyDirectory" );
/*do your stuff here */
}
else if ( iGathered == '*' )
{
ivrTwilRes.redirect( { method : 'GET' } , "/abcxyzDemoIvrMenu" );
}
else
{
ivrTwilRes.say("I'm sorry, that is not a valid choice. Please make a choice from the menu").redirect( { method : "GET" } );
}
ivrTwilRes.say("Thank you for calling my IVR . Goodbye.",
{
language:'en-gb',
voice : 'woman'
}
)
.pause({ length : 3 } )
.hangup();
o_Res.set('Content-Type','text/xml');
o_Res.send(ivrTwilRes.toString());
console.log("========================== Response Starts Here (for abcxyzDemoIvr post)============================");
console.log(o_Res);
console.log("========================== Response Ends Here (for abcxyzDemoIvr post)============================");
}
);
app.post('/abcxyzDemoIvr_CallAgent',
function(i_Req,o_Res)
{
var ivrTwilRes = new twilio.TwimlResponse();
var agentNum=i_Req.body.Digits ;
/*
console.log("========================== Request Starts Here (for abcxyzDemoIvr_CallAgent post)============================");
console.log(i_Req.body);
console.log("========================== Request Ends Here (for abcxyzDemoIvr_CallAgent post)============================");
*/
var whichAgent = /*your logic to get which number to dial */
ivrTwilRes.say("Connecting you to agent " + whichAgent )
.dial({callerId:'+447777777777',action:"/abcxyzDemoIvr_postCallHandler",method:"GET"},
function()
{
this.number('+44xxxxxxxxxx',{url:"/abcxyzDemoIvr_screenCaller",method:"GET"});
}
);
o_Res.set('Content-Type','text/xml');
o_Res.send(ivrTwilRes.toString());
}
);