【问题标题】:Interactive voice menu on Twilio/TwiMLTwilio/TwiML 上的交互式语音菜单
【发布时间】:2018-02-21 04:25:50
【问题描述】:

我需要一个与 TwiML 配套的交互式菜单,但我有几个问题:

  1. 我可以纯粹在 TwiML 中完成,还是需要一个带有表单处理的服务器端安装?
  2. 我需要基本上接听电话,询问用户几个选项(按 1 为 yada yada,按 2 为 blah blah),并根据响应需要拨打一个或另一个号码。有点像交互式总机

以上可能吗?关于我如何去做的任何迹象?

【问题讨论】:

标签: twilio voice twilio-twiml


【解决方案1】:

这里是 Twilio 开发者宣传员。

您无法使用静态 TwiML 生成交互式菜单,您需要能够对所采取的选择做出反应并且需要服务器端组件的东西。

谢天谢地,您有一些选择。

正如 Alex 在 cmets 中指出的那样,Twilio Studio 是 Twilio 的可视化构建器,它允许您创建这样的流程并将服务器端组件留给 Twilio。 video tutorialguide 向您展示了如何使用 Studio 构建 IVR。

另一方面,如果您乐于编写代码来创建这类东西,但又不想托管它,那么Twilio Functions 可能就是您要找的东西。 Twilio Functions 是用于运行代码的无服务器环境。您可以使用 TwiML Bin 编写初始 TwiML,因为它可以是静态 TwiML,如下所示,它使用 <Gather> 收集用户输入:

<Response>
  <Gather action="FUNCTION_URL" numDigits="1">
    <Say>Welcome to my menu, please press 1 for sales or 2 for support</Say>
  </Gather>
</Response>

然后在函数中,您需要编写一些 Node.js 来响应传入的Digits parameter,一旦用户输入它们,&lt;Gather&gt; 将发送到action URL。你可以用一个看起来有点像这样的函数来回应它:

exports.handler = function(context, event, callback) {
  const twiml = new Twilio.twiml.VoiceResponse();
  if (event.Digits === '1') {
    twiml.dial(SALES_NUMBER);
  } else if (event.Digits === '2') {
    twiml.dial(SUPPORT_NUMBER);
  } else {
    const gather = twiml.gather({ action: 'FUNCTION_URL', numDigits: '1' })
    gather.say('That was not an option, please dial 1 for sales and 2 for support')
  }
  callback(null, twiml);
}

taking user input using &lt;Gather&gt; 中还有一个更深入的指南。

让我知道这是否有帮助。

【讨论】:

  • 我最终在 nginx 实例上粘贴了一段丑陋的代码,并在我看到这篇文章之前让它工作。但我更喜欢 Twilio 函数的想法,并且会尝试!
  • 太棒了,希望一切顺利!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-19
相关资源
最近更新 更多