Twilio: is it possible to finish the <Dial> verb before timeout?

19 Views Asked by At

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.

1

There are 1 best solutions below

0
Sergei Reutov On

Ok, I think I found the way to do that:

  • I should simply use call.reject() instead of call.ignore()
  • rejecting doesn't mean it'll stop ringing for others
  • when all the Users reject the Call - the <Dial> will be finished with the busy status, and it'll trigger callbackUrl