You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检测Twilio <Say/>指令执行完成?

如何检测Twilio 指令的执行完成时间

你当前使用的XML指令集:

<Response>
  <Gather action="...">
    <Say>Hello</Say>
  </Gather>
</Response>

你尝试添加<Redirect>的方式无法实现预期,因为<Gather>必须等待超时时间结束才会执行后续指令,导致<Redirect>不会在<Say>播报完成后立刻触发。

可行解决方案

  • 拆分与执行流程
    不要将<Say>嵌套在<Gather>内部,先单独执行<Say>,播报完成后立刻通过<Redirect>触发回调端点,再在回调端点返回<Gather>指令:

    第一步返回的XML:

    <Response>
      <Say>Hello</Say>
      <Redirect>/start-gather</Redirect>
    </Response>
    

    在/start-gather端点返回的XML:

    <Response>
      <Gather action="...">
        <!-- 可添加用户输入提示,或直接等待输入 -->
      </Gather>
    </Response>
    

    这样<Say>播报完成后会立刻触发<Redirect>,你可以在/start-gather的处理逻辑中记录<Say>执行完成的事件。

  • 调整的timeout参数(折中方案)
    如果你必须将<Say>放在<Gather>内部,可以将<Gather>的timeout设为最小值1秒,这样<Say>播报完成后,只需等待1秒就会触发后续的<Redirect>:

    <Response>
      <Gather action="..." timeout="1">
        <Say>Hello</Say>
      </Gather>
      <Redirect>/say-finished</Redirect>
    </Response>
    

    注意:此方法会缩短用户输入的等待时间,可能影响交互体验,仅适合对输入响应时间要求不高的场景。

内容的提问来源于stack exchange,提问作者Ostap Maliuvanchuk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 02:05:43