【问题标题】:How to use a Twilio function to transfer a call to a phone number with an extension?如何使用 Twilio 功能将呼叫转移到带有分机的电话号码?
【发布时间】:2018-10-27 13:07:58
【问题描述】:

我正在尝试使用 Twilio 功能将呼叫转接到带有分机号的电话号码。

从 Twilio 流中调用 Twilio 函数。

现在,呼叫转移到电话号码。但是,该扩展永远不会被调用。

我在“sendDigits”中添加了一些“w”字符来暂停......但它没有改变任何东西。

Here is my Twilio flow

Here is my Twilio function widget with the parameter

这里是twilio函数的代码

exports.handler = function(context, event, callback) {
  // set-up the variables that this Function will use to forward a phone call using TwiML

  // REQUIRED - you must set this
  let phoneNumber = event.PhoneNumber || "NUMBER TO FORWARD TO";    
  // OPTIONAL
  let callerId =  event.CallerId || null;
  // OPTIONAL
  let timeout = event.Timeout || null;
  // OPTIONAL
  let allowedCallers = event.allowedCallers || [];

  // generate the TwiML to tell Twilio how to forward this call
  let twiml = new Twilio.twiml.VoiceResponse();

  let allowedThrough = true;
  if (allowedCallers.length > 0) {
    if (allowedCallers.indexOf(event.From) === -1) {
      allowedThrough = false;    
    }
  }

  let sendDigits = event.sendDigits;
  let dialParams = {};
  dialParams.sendDigits = sendDigits

  if (callerId) {
    dialParams.callerId = callerId;
  }
  if (timeout) {
    dialParams.timeout = timeout;
  }

  if (allowedThrough) {
    twiml.dial(dialParams, phoneNumber);
  }
  else {
    twiml.say('Sorry, you are calling from a restricted number. Good bye.');
  }

  // return the TwiML
  callback(null, twiml);
};

有什么想法吗?

【问题讨论】:

    标签: twilio twilio-functions


    【解决方案1】:

    Dial 动词没有 sendDigits 属性,但 REST API 有。

    您可以使用带有 Dial 动词 https://www.twilio.com/docs/voice/twiml/number 及其关联 URL 参数的 Number 名词来引用具有 Play 的 TwiML Bin https://www.twilio.com/docs/voice/twiml/play 及其数字属性,以便在被叫方应答后播放 DTMF电话,但在双方相互通信之前。

    【讨论】:

    • 根据您的反馈,我设置了一个“TwiML Bin”。使用电话分机(直接电话号码关联)转接电话非常有用。有没有一种简单的方法可以从 Twilio Function 或 Twilio Flow 调用“TwiML Bin”。这里的参数很好,但不是强制性的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    • 1970-01-01
    相关资源
    最近更新 更多