最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

twilio - Twlio gather not working at first attempt - Stack Overflow

programmeradmin2浏览0评论

I have everything working with my Twilio API. But recently I discovered a weird issue. I am trying to gather zip code from callers. It works if the caller enters the zip code immediately. But somehow if the caller delays for like 4-5 seconds to enter the zip code then Twilio plays the gather message again.

Here is my code:

$response = new VoiceResponse;
$gather = $response->gather(['numDigits' => 5, 'timeout' => 10, 'action' => 'api/twilio-gather-handle']);
$gather->say("Please enter your zip code.");
$response->redirect('api/twilio-gather-handle');
return $response;

So if callers enters their zip code immediately after Twilio message is played, everything works smoothly but if the callers delays like 4-5 seconds then gather does not work and Twilio plays "Please enter your zip code." again. So callers hear this the second time and they disconnect the call which is hurting out application very much.

Any help please?

I have everything working with my Twilio API. But recently I discovered a weird issue. I am trying to gather zip code from callers. It works if the caller enters the zip code immediately. But somehow if the caller delays for like 4-5 seconds to enter the zip code then Twilio plays the gather message again.

Here is my code:

$response = new VoiceResponse;
$gather = $response->gather(['numDigits' => 5, 'timeout' => 10, 'action' => 'api/twilio-gather-handle']);
$gather->say("Please enter your zip code.");
$response->redirect('api/twilio-gather-handle');
return $response;

So if callers enters their zip code immediately after Twilio message is played, everything works smoothly but if the callers delays like 4-5 seconds then gather does not work and Twilio plays "Please enter your zip code." again. So callers hear this the second time and they disconnect the call which is hurting out application very much.

Any help please?

Share Improve this question asked Jan 21 at 11:49 Yunus AslamYunus Aslam 2,4664 gold badges28 silver badges43 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I think this might be related to the redirect you have after the gather. I assume your /api/twilio-gather-handle endpoint checks for the needed parameter and redirects back if they are missing. This is why the user hears it twice.

You can fix this by removing the redirect. The endpoint is known to the gather because of the action property.

发布评论

评论列表(0)

  1. 暂无评论