We have an app that uses Twilio (with TwiML), and we'd like to implement the following logic:
- an incoming Call is being directed to multiple Users
- if all of them ignores the Call, it should be routed to the pre-defined phone number
TwiML we return at the Call start:
<Dial callerId="{incomingNumber}" action="{callbackUrl}" timeout="30">
<Client statusCallbackEvent="answered completed" statusCallback="{statusCallbackUrl}">
<Identity>{userId1}</Identity>
</Client>
<Client statusCallbackEvent="answered completed" statusCallback="{statusCallbackUrl}">
<Identity>{userId2}</Identity>
</Client>
</Dial>
If this <Dial> wasn't answered in 30 seconds, it goes to our callbackUrl, which returns the following:
<Dial callerId="{incomingNumber}" action="{callbackUrl}" timeout="30">
<Number>{phoneNumber}</Number>
</Dial>
And it works as it should, but my question is - can we finish the first <Dial> before the timeout if both Users ignored the Call (using call.ignore() from Twilio Voice JavaScript SDK).
We also can keep track of who received a Call, and who clicked ignore, but I still don't know if there's a way to finish the current <Dial> before the timeout.
Ok, I think I found the way to do that:
call.reject()instead ofcall.ignore()<Dial>will be finished with thebusystatus, and it'll triggercallbackUrl