0

I have a Twilio number, a SIM and a SIP account. Is it possible using Twilio to forward an incoming call to SIM, if there is no answer it will forward to SIP, if there is still no answer from SIP it will say a message and record the voice.

Thach Nguyen
  • 120
  • 7

1 Answers1

1

Twilio developer evangelist here.

I answered a very similar question here on Stack Overflow. This type of call is known as Find Me or Hunt.

My solution, which I wrote up and published as a usable Twilio Function here: https://github.com/philnash/useful-twilio-functions/blob/master/hunt/hunt.js (see the documentation here).

That currently only works with numbers formatted as E.164 international numbers. However, you could add SIP support to it with the following code.

Instead of just dialling a number at the end (dial.number(numberToDial)), we'd need to work out whether we had a number or a SIP address and setup the dial accordingly.

if (numberToDial.indexOf('@') > 0) {
  dial.sip(numberToDial);
} else {
  dial.number(numberToDial);
}

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thank you for your help and the `Hunt` keyword. I didn't know that we can pass the send new response for the `action` of dial. – Thach Nguyen Aug 28 '17 at 02:11
  • No worries! Don't forget, action attributes just take a URL, so you can put anything into them that is a valid URL. Hope you solve your issue now :) – philnash Aug 28 '17 at 11:19