I\'m writing a call centre app using Twilio, and I\'ve run into a problem. The calls are received and put into a queue, while we find an agent to answer the call. Whilst t
I found a solution to this which doesn't mean anyone dropping out of the queue goes to voicemail, and it's to use the REST API to change the relevant call, dropping it from the queue and forwarding to another TWiML document which records your message.
Twilio developer evangelist here.
This behaviour is by design. The <Enqueue>
documentation provides you the verbs that can be used within the waitUrl TwiML. However, this does not mean that you are out of luck, we can still create this feature.
Instead of going from <Gather>
to <Say/><Record/>
you can use <Leave>
to have the user leave the queue. The call won't hang up, rather it will try to carry on from after the original <Enqueue>
. Add your <Say/><Record/>
in that original TwiML and it will play when the user decides to leave the queue and record a message.
So, you initial TwiML will now be:
<Response>
<Say voice="alice" language="en-AU">
Thanks for calling, please note all calls may be recorded for security and training purposes. We'll answer your call very shortly.
</Say>
<Enqueue waitUrl="http://ngrok.com/holdMusic">1COVERAUS</Enqueue>
<Say voice="alice" language="en-AU">
Please record your message after the tone.
</Say>
<Record action="http://ngrok.com/handleVoicemailRecording"></Record>
</Response>
Your waitUrl TwiML stays the same:
<Response>
<Gather numDigits="1" action="http://ngrok.com/leaveVoicemail">
<Say>
Thanks for waiting, you're 1 in the queue. Press 1 at any time to leave a message.</Say>
<Play>https://s3-ap-southeast-2.amazonaws.com/somemusic.mp3</Play>
</Gather>
</Response>
And the Gather action simply becomes:
<Response>
<Leave/>
</Response>
Let me know if that helps at all.