Twilio点击通话并收集数字

时间:2017-08-26 13:18:50

标签: node.js twilio twilio-click-to-call

我已经开发了一个网络,可以按照本教程将两个人连接到一个电话中: https://www.twilio.com/docs/tutorials/click-to-call-node-express 一切都很好。

现在我需要收集一个被调用者的数字才能执行命令。

阅读Twilio文档似乎在Dial动词结束之前我不能使用Gather,但这样调用就会被关闭,而被调用者无法对任何内容进行数字化。

我尝试了这个没有成功,拨号工作正常,但数字回调永远不会执行:

twimlResponse.say(
    'Please wait for the other person to join the call'
  );

  twimlResponse.dial({
    timeLimit: 30
  })
  twimlResponse.dial(to_number)

  const gather = twimlResponse.gather({
    input: 'dtmf',
    timeout: 30,
    numDigits: 1,
    action: url // the url is the callback that should handle the digit entered
  });

这是Twilio的限制吗?任何变通方法或替代呼叫策略?

1 个答案:

答案 0 :(得分:1)

我认为您需要发送一个url并使用您拨打的number,并让该网址响应您希望与被叫方进行互动的TwiML。来自https://www.twilio.com/docs/api/twiml/number

  

'url'属性允许您为TwiML文档指定URL   在她回答之后,但在此之前,它将在被叫方的最后运行   各方有联系。您可以使用此TwiML私下播放或   向被叫方说出信息,或提供拒绝的机会   使用<Gather><Hangup>拨打电话。

这样的事情:

const dial = twimlResponse.dial({
  timeLimit: 30
});
dial.number({
  url: urlToGather // respond to this URL with your <Gather> TwiML
}, to_number);
相关问题