How to set up Twilio Elastic SIP Trunking with Odoo PBX

Twilio Configuration

  1. Go to Twilio website at and log into your Twilio account. Click on the All Products and Services button and select Elastic SIP Trunking.

  2. On the Trunk Dashboard page go to the Trunks section and add a new trunk by clicking on the plus sign in the blue circle as shown in the screenshot below.

    Sample Twilio trunk
  3. You will see a “Create a New SIP Trunk” form, that asks for the new trunk’s friendly name.

    Form for creating new trunk in Twilio
  4. After you click on the Create button, the settings page for a new trunk is opened. Go to the Termination page. There you’ll be asked for the Termination SIP URI. You need to add an unique name for your trunk, for example odoopbxdocs

    Sample termination URI:

    This is the global termination URI - Twilio generates local termination URIs for different regions, as shown when clicking on Show Localized URIs button.

  5. Scroll down to the Authentication section. There you need to create at least an authentication list: either an IP Access Control List or a Credential List. The IP Access Control List is used when your PBX has a fixed IP address. If you set only the IP Access Control List, you can connect only from the IP addresses included there. Also, if you set only a Credential List, the Trunk connection is performed using a username and a password.

    Sample authentication by using IP Access Control Lists

    You can click on the plus sign on the right to create either one. For an IP Access Control List you need to add a friendly name, an IP address or a subnet and a friendly name for that address or subnet.

    Creation of a new IP Access Control List

    For a Credential List you need to write a friendly name, a username and a password.

    Creation of a new Credentials Access Control List

    You can also access the Credentials page from Twilio homepage by going to All Products and Services -> Elastic SIP Trunking -> Authentication.

  6. Go to the Origination page. There you need to set up the URI from which the calls will come.

    List of Originations in Twilio

    Click on the plus sign to add a new origination URI. This is the URI you use for logging in to your server. In case you are using a non-standard SIP port, add the port as well. For example, with the domain, port 6053, you need to set the URI to

    Adding an Origination URI in Twilio
  7. Go to the Numbers page to add a number to the trunk.

    Numbers list in Twilio

You can choose a number you have already bought, buy a single number or buy multiple numbers in bulk.

This finishes the trunk configuration on Twilio, next you have to go to your Odoo instance and configure the trunk.

Odoo PBX Configuration

  1. Go to PBX -> Files and click on Create. Set the file name to sip_twilio.conf and the desired server. Copy the contents of the file from below and paste them into the Content field.

    Twilio SIP config in Odoo

    Save the file. File contents:

    ; Ireland Signalling Gateways
    ; North America Virginia Signalling Gateways
    ; North America Oregon Signalling Gateways
    ; Europe Frankfurt Signalling Gateways
    ; Asia Pacific Tokyo gateways
    ; Asia Pacific Singapore gateways
    ; Asia Pacific Disney gateways
    ; South America Sao Paulo gateways
  2. Go to PBX -> Files, remove the Updated filter and search for sip.conf. To the end of the file add the line:

    #tryinclude sip_twillio.conf`
  3. Go to PBX -> Applications -> Trunks and create a new trunk with the following fields:

Host: Select the closest to you Termination URI from the Twilio website (All Products and Services -> Elastic SIP Trunking -> Trunks -> choose your trunk -> Termination).

From user: The username from Twilio’s Credential List, if you have set it up. Otherwise leave empty

SIP Secret: The password from Twilio’s Credential List. Leave empty if not set.

DMTF mode: RFC2833

Allow Codecs: opus,ulaw (Only ulaw is supported by default but you can ask Twilio to enable Opus and a few other codecs)

Disallow Codecs: All


Can reinvite: No

Route Groups: Incoming

The trunk configuration is finished. Next you need to create incoming and outgoing routes for your users, so they could call and receive calls.

Creating outgoing and incoming routes in OdooPBX

First you need to create an outgoing route. Go to PBX -> Applications -> Routes and click on Create. Next fill in the fields:

Destination number: _XXXXXXX. This means that any phone number with more than 7 digits will be directed to the trunk

Prio: 0

Type: SIP Trunk

SIP Trunk: the name of the trunk created above

Dial Timeout: 60

Dial Options: T

Record Calls: Mark if you need the calls to be recorded

Destination number translation

Twillio requires numbers to be sent in E.164 format (with +). So you need to create a translation rule that will prefix all numbers with +:

Set up Destination Translation for Twilio

Source number translation

Next click on the Number Translation tab and click on Add a line for the Source Numbers field. After that click on Create and you will see the following form:

Set up Source Translation for Twilio

Click on the User field and choose what user you need to use the trunk number. Next in the Replace field enter the number in E.164 international format starting with +.

Next you need to create an incoming route, denoting the receiver of the incoming calls. Go to PBX -> Applications -> Routes and click on Create and fill in the fields:

Destination number: The phone number, without the + sign

Type: Can be Extension or Dialplan and select the dialplan or extension you want to redirect the call to.

Click on Save and next on Apply Changes. Test the incoming and outgoing calls.