使用Node.js通过Twilio直接拨打电话

huangapple go评论79阅读模式
英文:

making a direct phone call using Twilio on Node.js

问题

我在使用Node.js上的Twilio时遇到了一个直接拨打电话的问题,以下是我尝试过的代码:

...
   client.calls
      .create({
         twiml: '<Response><Dial><+122*********</Dial></Response>',
         to: '+122*********',
         from: '+144444*******'
       })
...
       

使用上述代码后,我发送请求后,接收者会收到来自发送者(+14444****)的电话,一旦接收者接听电话,他会接到来自不同号码的另一个电话,所以我有点困惑发生了什么情况。

英文:

i am having an issue making a direct phone call using twilio on Node.js,
bellow is what i have tried

...
   client.calls
      .create({
         twiml: '<Response><Dial><+122*********</Dial></Response>',
         to: '+122*********',
         from: '+144444*******'
       })
...
       

with the above code, after i sent the request, the receiver will get a phone call from the sender(+14444****) and once he picked up the call, he will then receive another call from different number so i am a bit confused on what is happening,

答案1

得分: 1

这是因为您两次发起呼叫,第一次是通过 calls.create(),然后是通过 TwiML 节点 <Dial>。您可以完全移除 Dial 节点,直接从 TwiML 指令开始:

   client.calls
      .create({
         twiml: '<Response> <Say>你好</Say><Pause length="60" /></Response>',
         to: '+122*********',
         from: '+144444*******'
       })
英文:

This happens because you create the call twice, the first time via the calls.create() and then via the TwiML node <Dial>. You can remove the Dial node entirely and start right away with the TwiML instructions:

   client.calls
      .create({
         twiml: '<Response> <Say>Hi</Say><Pause length="60" /></Response>',
         to: '+122*********',
         from: '+144444*******'
       })

huangapple
  • 本文由 发表于 2023年6月22日 02:40:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526236.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定