簡體   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