Twilio added SIP Registration as a feature in October 2016.
https://www.twilio.com/blog/2016/10/introducing-sip-registration.html
Incoming Calls
SIP Registration allows you to connect a SIP device in order to receive INCOMING calls to your number. Basically your device is "registered" with twilio so that twilio knows your device exists and can ring it when there is an incoming call.
To get incoming calls working, you should login to twilio, have a phone number and configure a SIP domain under "Programmable Voice":
- Add a SIP Domain (e.g. mysipdomain.sip.twilio.com).
- Add a user/credential to that sip domain
Note that you can use either mysipdomain.sip.us1.twilio.com
or mysipdomain.sip.twilio.com
. Obitalk defaults to the former but the twilio UI shows the latter. Both work for now.
Login to the obitalk dashboard and configure one of the available SP on your Obihai box to use Twilio.
- Enter your twilio sip domain (e.g.
mysipdomain
)
- Provide the sip username and password that you configured in twilio as part of the sip domain.
- save
The obitalk dashboard should show successful sip registration for the SP you configured and you should be able to dial your Twilio number and have your SIP phone ring.
Outgoing Calls
In order to handle outgoing calls from your SIP registered phone, you need to provide a URL under "Voice Configuration" under the SIP Domain in Twilio. When your SIP registered device tries to make an outgoing call, Twilio will ask this URL for instructions on what to do.
This is the harder part because you need to host a small web application somewhere for twilio to talk to (no twimlet available as of today). The web application itself can be quite simple if all we want to do is parse the request and tell twilio to <Dial>
the requested number. If you are doing any international dialing you should make sure you have enabled these countries in your account.
Here is one opensource application you can use for this purpose.
https://github.com/timbeyers/sip2pstn-simpledial
I have a quick and dirty php implementation that I prefer (due to the ease of hosting on almost any cheap shared hosting plans).
https://gist.github.com/mattpr/9ed8f97f0a7a184c17da99a3d2463e7a