简体   繁体   English

Twilio节点-浏览器到电话的StatusCallback事件

[英]Twilio node - Browser to phone StatusCallback events

I am trying to get back StatusCallback events when I dial from my browser to phone call. 当我从浏览器拨打电话时,我试图找回StatusCallback事件。

When user clicks on dial in browser I am sending the following response to twilio: 当用户单击浏览器中的拨号时,我将向twilio发送以下响应:

  const dial = twiml.dial({
    callerId: Meteor.settings.private.twilio.TWILIO_CALLER_ID,
    answerOnBridge: true,
    record: "record-from-answer-dual",
    StatusCallbackEvent: ["initiated", "ringing", "answered", "completed"],
    StatusCallback,
    recordingStatusCallback: recordURLCallback,
  });
  dial.number(toNumber);

I have registered webhook both in twilio console and also sending via command but i'm not receiving 'ringing', 'answered' events from twilio 我已经在twilio控制台中注册了Webhook,也通过命令进行了发送,但是我没有从twilio接收到“振铃”,“已应答”事件

   WebApp.connectHandlers.use("/twilio-status-callback", function( req, res, next ) {
     console.log('***status url callback***');
     var body = "";
     req.on('data', Meteor.bindEnvironment(function (data) {
       body += data;
     }));
     req.on('end', Meteor.bindEnvironment(function () {
      body = qs.parse(body)
      console.log(body);

      res.end();
    }));
  });

I am only receiving completed event, how to get other statuses to so that I can show ringing UI when it is ringing and hangup button when answered? 我只收到completed事件,如何获取其他状态,以便在振铃时可以显示振铃的UI,并在回答时可以挂断按钮?

Twilio developer evangelist here. Twilio开发人员布道者在这里。

In your example code you don't include an option for StatusCallback so there is no webhook for Twilio to call, only a recordingStatusCallback . 在您的示例代码中,您没有包括StatusCallback的选项,因此没有用于Twilio调用的webhook,只有recordingStatusCallback Also, the Node library actually translates the keys from lower-camel-case, so the keys should be statusCallback . 另外,Node库实际上是statusCallback转换键,因此键应为statusCallback Try updating the code to something like this and let me know how it goes: 尝试将代码更新为这样的内容,让我知道它的运行方式:

const dial = twiml.dial({
  callerId: Meteor.settings.private.twilio.TWILIO_CALLER_ID,
  answerOnBridge: true,
  record: "record-from-answer-dual",
  statusCallbackEvent: ["initiated", "ringing", "answered", "completed"],
  statusCallback: statusURLCallback,
  recordingStatusCallback: recordURLCallback,
});
dial.number(toNumber);

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

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