当输入只有 finishOnKey 时,如何防止 Twilio Gather 挂断?

How to prevent Twilio Gather from hanging up when the input is ONLY the finishOnKey?

我们有一个简单的案例,用户将拨打我们的 phone 号码,在某些情况下需要输入 PIN,然后输入井号,以进行身份​​验证并继续。在这种情况下,井号被定义为我们的 finishOnKey.

如果用户输入 PIN,则一切正常。如果有效,他们继续前进;如果不是,它会阻止它们。

但是,如果用户只按了英镑,而没有任何预先输入,呼叫就会挂断。

这让我相信这要么是 Twilio 内置的,要么我的代码中可能缺少某些东西,但我无法想象是什么。这是 Twilio 的预期行为吗,and/or 如何预防?我们希望系统简单地做出反应,就好像用户输入了无效的 PIN 码一样。

这里是 Twilio 开发人员布道者。

来自<Gather> documentation on the action attribute

If the 'timeout' is reached before the caller enters any digits, or if the caller enters the 'finishOnKey' value before entering any other digits, Twilio will not make a request to the 'action' URL but instead continue processing the current TwiML document with the verb immediately following the <Gather>.

我假设您的 <Gather> 之后没有任何 TwiML,因为您希望它始终提交给 action URL。我推荐你<Say> a message to the user and then <Redirect>回到原来的URL,有点像这样:

<Response>
  <Gather finishOnKey="#" action="https://example.com/gather_response">
    <Say>Please enter the PIN</Say>
  </Gather>
  <Say>We did not receive a PIN, please try again.</Say>
  <Redirect>https://example.com/gather</Redirect>
</Response>

如果有帮助请告诉我。