【问题标题】:How do you access the information gathered on a Twilio phone call?您如何访问通过 Twilio 电话收集的信息?
【发布时间】:2021-10-04 09:17:04
【问题描述】:

我有以下代码:

<?xml version="1.0" encoding="UTF-8"?>
<!-- page located at http://example.com/simple_gather.xml -->
<Response>
  <Pause length="2"/>  <Play>https://welcomehisheart.com/wp-content/uploads/2021/10/congress-invitation.mp3</Play>
  <Pause length="1"/>
    <Say>If you would no longer like to receive information about the Sacred Heart, press 2</Say>
    <Gather/>
  <Pause length="1"/>
</Response>

TwiML URL 是:

https://handler.twilio.com/twiml/EHe23193a659bfcf74b1061864aea9b224

代码按预期工作。您可以在通话过程中输入选择。

如何访问收集到的信息?

谢谢

【问题讨论】:

    标签: twilio twilio-api twilio-twiml


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    看起来您正在使用TwiML Bin,这对于像第一条消息这样的静态 TwiML 片段非常有用。但是,有几个问题。

    首先,您没有给用户适当的时间来输入他们的输入。 &lt;Gather&gt; 元素最好与嵌套在其中的消息一起使用,以便用户可以随时按下。您还可以设置timeout 以更好地控制嵌套&lt;Say&gt; 完成后他们必须响应的时间。 timeout 的默认值为 5 秒。

    其次,如果您只是在等待用户按单个数字,您可以将numDigits="1" attribute 添加到&lt;Gather&gt;。一旦用户按下一个数字,这将完成&lt;Gather&gt;

    最后,关于您的问题,您需要为&lt;Gather&gt; 提供一个URL,即action attribute。然后,当用户按下某个键时,Twilio 将使用他们的输入结果向该 URL 发出 HTTP 请求。您需要构建一个应用程序来处理该请求并对按键的结果进行处理。

    因此,您应该将 TwiML 更新为:

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- page located at http://example.com/simple_gather.xml -->
    <Response>
      <Pause length="2"/>
      <Play>https://welcomehisheart.com/wp-content/uploads/2021/10/congress-invitation.mp3</Play>
      <Pause length="1"/>
      <Gather numDigits="1" action="https://example.com/gather">
        <Say>If you would no longer like to receive information about the Sacred Heart, press 2</Say>
      </Gather>
    </Response>
    

    并且您需要创建一个可以接收 HTTP 请求的应用程序,在本例中为 URL example.com/gather,但您应该在此处提供自己的 URL。

    tutorials on how to gather user input in a phone call 将通过代码示例更深入地介绍这一点,您应该接下来阅读。

    【讨论】:

    • 感谢您的详细回复!非常感谢!
    • 没问题。如果对您有帮助,请确保将答案标记为正确!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 2016-12-16
    相关资源
    最近更新 更多