繁体   English   中英

Twilio Node.js API - 使用“拨号”转发呼叫时遇到问题

[英]Twilio Node.js API - Trouble using 'Dial' to forward call

我在使用Twilio Node.js库让“拨号”转发呼叫时遇到了一些麻烦。 这个库的文档很少,使用“拨号”的唯一示例是电话会议:

.dial({
            action:'http://example.com/something.php'
        }, function(node) {
            node.conference('waitingRoom', {
            beep:'false'
        });
    });

使用此功能,我可以使用以下代码生成与拨号文档中类似的XML:

.dial('number', {
                  action: 'http://url'
                  hangupOnStar: true
                }, (err, respData) => {
                  console.log(err);
                  console.log(respData);
                })

这导致呼叫立即转发到action URL。

我还尝试在他们的文档中使用第三个示例, Example 3: Dial to a phone number from Twilio Client ,生成以下XML:

<Response>
    <Dial hangupOnStar="true" callerId="number">
        <Number>number to call</Number>
    </Dial>
</Response>

通过以下代码:

resp.dial({
                  hangupOnStar: true,
                  callerId: 'number'
                }, (node) => {
                  node.number('number')
                })

我正在测试的这些数字是有效的数字,我也尝试过不同的格式。 任何想法如何让这个工作? 任何帮助表示赞赏。

要转发呼叫,流量可能是类似的

  1. 将Twilio号码的语音URL设置为端点,当此Twilio号码接收呼叫时,该端点会返回TwiML响应。
  2. 在此端点中,TwiML响应应<Dial>要将呼叫转发到的<Number> 这将桥接来电,即将其转发到您想要的号码。

我在下面提到了一个可以执行此操作的示例代码

app.get("/forwardToMyMobile",function(i_Req,o_Res)
   {
               var ivrTwilRes = new twilio.TwimlResponse();
               var numberToForwardCallTo=i_Req.query.toNumber; 
               /*In case you want to pass this number as querystring ,
                 else if its a fixed number you can just hardcode it */


              ivrTwilRes.dial({callerId:'+44xxxxxxxx'},
                                function()
                                             {
                                                  this.number(numberToForwardCallTo);

                                             }
                                        )
                           .record();

               o_Res.set('Content-Type','text/xml');
               o_Res.send(ivrTwilRes.toString());
   });

当您的Twilio号码立即收到呼叫时,它将在您的nodejs服务器应用程序上webhook到“/ forwardToMyMobile”,并指示Twilio转发呼叫。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM