【问题标题】:IVR in TwiML; how do I set keypresses to dial particular numbers?TwiML 中的 IVR;如何设置按键以拨打特定号码?
【发布时间】:2016-10-03 04:14:08
【问题描述】:

我正在尝试在 Twilio 网站上使用 TwiML 编写 IVR。理想情况下,我希望发生的是:

  • 按“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>

【问题讨论】:

    标签: twilio twilio-twiml


    【解决方案1】:

    你是对的 - 你必须对 .此操作 URL 将获得用户按下的“DIGITS”,然后您可以采取适当的操作。

    请参阅下面的示例 (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>
    

    下面还提到了如何组织&lt;Gather&gt; 的操作 URL 的示例:

    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());
    
    
               }
           );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2015-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多