Eva611
Eva611

Reputation: 6194

Twilio - Twiml Enqueue timeout or redirect after fixed time

Is there a way to redirect a call in a queue after a certain amount of time? I know in a Twiml <Dial> you can set a timeout. Is there any way to do that in <Enqueue> or even <Play> as part of it's waitURL

Right now I'm doing something like this:

<Response>
    <Enqueue waitUrl="/wait/" method="GET">
        Support
    </Enqueue>
</Response>

and my wait URL is:

<Response>
    <Play>http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3</Play>
</Response>

I want to redirect the caller to voicemail if he/she has been in the queue for more than 60 seconds.

Upvotes: 4

Views: 2398

Answers (2)

BMan62
BMan62

Reputation: 1

On The response, set the Play loop="x" and below that do a redirect.

<Response>
    <Play loop="2">http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3</Play>
    <Redirect>https://webhooks.twilio.com/v1/Accounts/{ACT ID}/Flows/{FLOW ID}?FlowEvent=return</Redirect>
</Response>

Upvotes: 0

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

I don't beleive there is a way to set a Timeout attribute on the enqueue verb. I think there are a couple of ways you can approach this:

  1. In your waitUrl, use an mp3 that is shorter than 60 seconds. When the track is done playing, Twilio will make another request to the waitUrl and pass you a QueueTime parameter which will tell you how long the caller has been in the queue. If that time is > 60 seconds you can redirect that call.
  2. Have a process running in your app that uses the REST API to poll the queue members and checks their waitTime. If waittime > 60 seconds, you redirect the call.

Hope that helps.

Upvotes: 9

Related Questions