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 badges1 Answer
Reset to default 0I 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.