Update: I got it working https://github.com/coolaj86/bizilio
I have this scenario where a customer makes a call and that call should be forwarded to the first representative to answer (let's just focus on one for the moment).
The problem is that occasionally the rep butt-answers or the phone is off and goes straight to voicemail, which is detected as an answer.
What I would like to do is put up a challenge such as using gather & say "press 2 to answer" with a 5 second timeout and then connect the call (or drop the call) and if no rep responds go to voicemail.
I'm not clear on how to connect the person who presses 2 to the phone that's ringing.
Twilio evangelist here.
So just to make sure I understand your question. You've got customers making inbound calls and for each customers calling, you're dialing a bunch of reps. But you want to make sure that the rep actually wants to accept that call by issuing a "challenge" of some kind that require explicit action on their part to complete.
This is totally possible with Twilio and most of how to do it is described in these HowTos:
https://www.twilio.com/docs/howto/callscreening (press * to answer this call)
https://www.twilio.com/docs/api/rest/answering-machine-detection (answering machine detection)
Their are two key parts of this HowTo.
First, it uses the Number noun to dial the second leg of the call. In your case this is dialing a rep. The
<Number> noun has a url attribute that lets you provide a URL that Twilio will request when the rep answers. This give you the opportunity to provide some TwiML that Twilio will execute for that leg of the call. So you can for example prompt the rep to press the number 2.
<Dial> verb has its action attribute set. This URL will be requested when the second leg of the call to the rep ends and gives you the opportunity to take some other action. So if the agent does not answer or fails press 2 within the require time, their call ends and your app can make a call to another rep.
Hope that helps.
Devin's answer is correct, but the
< Number > verb is always a bit tricky to use.
What you can also do is use the Find Me twimlet, or figure out how to code that twimlet in your app if you chose not to use premade twimlets.
The concept is that it dials up to 10 numbers, one by one. Even if you don't use all 10 numbers, you can enter enough to make sure that the call is eventually answered by a human *no matter what.*
Otherwise, another solution that I used in my Twilio App is before you dial them, you tell them in your verb that if they hit a voicemail, that they don't leave a message there as it WILL NOT be answered. Then, if they press 1 while listening to the phone's voicemail, it will HANG UP (but not disconnect them) they will not leave a message to that voicemail and be redirected to your TwiML.
— You then redirect them to a Voicemail Twimlet —>
where you ask them to leave an email and phone number and Twilio emails you the audio. That way you can answer their concern at a later time.
The TwiML should look like :
< Say > Bla bla dont answer first voicemail < /Say >
< Dial> the rep # < /Dial>
//Depending on answer, if it's missed they exit the Dial verb.
< redirect > "the voicemail url" < /redirect >
(go read the Voicemail page to understand how to customize it to your choosing/business logic.)