Register SIP account and receive calls with Twilio


I live in three different countries and have friends, family members, and colleagues in each of them. As a result, I need to maintain phone numbers in each country for 2FA, e-signatures, and making and receiving calls. Although I do not use all three SIM cards at the same time, it is still important to receive phone calls.

Years ago, I used to run Asterisk PBX on VPS, but I nuked it a while ago as I did not want to maintain one extra piece of software. The national phone numbers (DID’s) were purchased from various providers, and some time ago, I switched to Twilio.

Twilio offers multiple options to maintain calls, one of which is TwiML. Let’s dive into it!

ISSUES FIRST! At the moment of writing (July 2023), Twilio offers POP’s in the EU (ie1), USA (us1), and Australia (au1). The full support of capabilities is possible with the US pop or I haven’t fount the way to get it working with the European pop. I spent some time attempting to deliver calls to the SIP trunk that is registered in the EU zone with error “32002 Your TwiML tried to Dial a Twilio SIP Domain that can’t be found”. So please be warned, and if you end up getting the EU pop working, please drop me a message.

Here are the steps you need to follow to set up Twilio:

  1. Go to https://console.twilio.com/us1/develop/voice/manage/cls and create your SIP credentials list. It is a list with a username-password match that you will need in the next step.
  2. Create a new SIP domain with a unique name at https://console.twilio.com/us1/develop/voice/manage/sip-domains. Enable SIP registration and select the credentials list you will use with this domain. Configure everything else (encryption, etc.).
  3. Create a TwiML bin with the following content at https://console.twilio.com/us1/develop/twiml-bins/twiml-bins:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <!-- Say>Hello from Twilio!</Say -->

  <Dial answerOnBridge="true" sequential="true" ringTone="lt" record="record-from-answer-dual" trim="trim-silence">
    <Sip>[email protected];region=ie1</Sip>
  </Dial>

  <!-- Simultaneous Dialing -->
  <Dial answerOnBridge="true" ringTone="es" record="record-from-answer-dual" trim="trim-silence">
    <Sip>[email protected];region=ie1</Sip>
    <Number>+YOURNUMBER</Number>
  </Dial>

  <Say>Hello, YOURNAME cannot answer. Please leave a message at the beep.</Say>

  <Record timeout="30" transcribe="true" playBeep="true"/>
</Response>
  1. Purchase a DID number at https://console.twilio.com/us1/develop/phone-numbers/manage/incoming and enter the inbound call routing section (A call comes in) to select the TwiML bin.
  2. Download a SIP client, such as Groundwire from Acrobits, and register it with Twilio using your username and password from the credentials list and the following registration domain: YOURDOMAIN.sip.twilio.com.
  3. Test inbound calls. If a call does not work, navigate to the logs at https://console.twilio.com/us1/monitor/logs/debugger/errors.

Now that everything is set up, redirect your phone calls to the Twilio DID number by dialing *21*+YOUR-TWILIO-NUMBER# on your mobile phone.