Issue
I'm using the twilio php api and I can't seem to find any way to interrupt the audio files from playing immediately a gather key is pressed.
This is what I have currently
$voiceResponse->gather(['method' => 'POST', 'action' => $storeResponseURL, 'finishOnKey' => '#']);
$voiceResponse->redirect($noResponseURL, ['method' => 'POST']);
Please, I need help on this.
Solution
Twilio developer evangelist here.
In your <Gather> from your example you have the finishOnKey attribute set to "#". So the <Gather> will only finish when your caller presses "#" not any other key.
Your <Gather> doesn't appear to contain any other TwiML either. If you want to be able to interrupt audio then you need to nest a <Say> or <Play> element inside the <Gather>.
If you want to complete the input after just one character, then your best bet is to actually use the numDigits attribute and set it to 1.
Putting that all together, your TwiML generation should look like this:
$voiceResponse = new Twiml();
$gather = $voiceResponse->gather(['method' => 'POST', 'action' => $storeResponseURL, 'numDigits' => '1']);
$gather->play('/gather_audio.mp3');
$voiceResponse->redirect($noResponseURL, ['method' => 'POST']);
Let me know if that helps!
Answered By - philnash Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.