Question

In my application I create outgoing call with REST API.

Call has machine detection enabled, so I at least can hang it up when machine answer is detected.

The questions is: can I dial another number in this case without creating new call with REST API? Can I use <Forward> or <Redirect> or something like this? Or there is no way to achieve this, and I need to create another call?

Was it helpful?

Solution

Twilio Evangelist here. So first thing, you can ask Twilio direct questions by contacting support on help@twilio.com.

So, this is quite a complicated question to work through. But I'm afraid the answer is that you cannot. Allow me to explain:

If you use the REST API to make an outbound call you have 2 ends to the call. The first is the number you have dialled out to (the callee), the second is the TwiML that is acting as your caller. You caller could be a robot (using <Say>, <Gather>, etc), or could be a <Dial> to another number.

If you look at the documentation, when Twilio makes the outbound call, you use the ifMachine attribute to determine how to handle the call. Twilio will then send you an extra parameter AnsweredBy indicating if it was a human or answering machine.

At this point, the TwiML that is acting as your caller is being requested. You can <Hangup> (or set ifMachine=Hangup so you won't be charged for this call) or choose to leave a message.

But what I think you are asking to do at this point is drop the outbound call, and then dial in a new callee to the caller. My first thought is that there is no elegant way to resolve this without making a new outbound call.

the thing to remember is that when Twilio requests the TwiML, it is expecting it to do something to the callee (answer machine in this case), and if you try and dial on to another number, you'll end up with the answer machine connected to that other number!

I think your best bet is to <hangup> in the TwiML, and make a new outbound call from your server at this point.

Best of luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top