This guide explains how to connect a 3CX Private Branch Exchange (PBX) instance and Twilio Elastic Session Initiation Protocol (SIP) Trunking. This includes setting up emergency calling.
To store values that you need between your 3CX PBX and your Twilio trunk, create a text file in your preferred text editor.
To create a 3CX PBX instance, log in to 3CX and create a 3CX-hosted PBX.
These settings configure how your trunk sends outgoing traffic to the PSTN and then the call recipient. This is also known as PSTN Termination.
If necessary, log in to your Twilio Console.
Click the link with your trunk name.
The General Settings page displays.
Click Termination in the left side navigation.
The Termination page displays.
Click Show Localized URIs.
A list of URIs for Twilio's various Edge Regions around the world appears.
Type a unique hostname for your SIP trunk in the Termination SIP URI field. The list of localized URIs update with your SIP trunk hostname prepended to their domain.
If you type mypbx
into the Termination SIP URI field, the North America Virginia localized SIP URI displays mypbx.pstn.ashburn.twilio.com
.
If you use the default SIP URI, traffic to your PBX routes to <SIP_HOSTNAME>.pstn.ashburn.twilio.com
.
To minimize latency, choose the SIP URI nearest to your physical PBX location.
Select the appropriate URI and copy this value.
Paste this value into the temporary text file.
Before you can save any settings on the Termination page, you must secure your SIP trunk. As you turned on Secure Trunking in the Create the SIP trunk in the Twilio Console section, Twilio can't continue until you configure an ACL and credentials for your trunk.
To secure your SIP trunk, configure an access control list (ACL) and credentials.
IP Address of ...
.A range of IPs from...
, you need to change the dropdown menu value to 32.INVITE
. It can be up to 32 characters long.The Twilio Console saves these settings without prompting on creation. When you change these settings, click Save to preserve the changes.
These settings configure how your trunk receives incoming traffic from a caller to the PSTN. This is also known as PSTN Origination.
sip:
into the Origination SIP URI field.Origination url added.
Trunk updated.
Each SIP requires at least one phone number. This number directs calls from the Public Switched Telephone Network (PSTN) to your trunk and acts as the caller ID for outbound calls.
If necessary, log in to your Twilio Console.
Click Numbers in the left side navigation.
The Numbers page displays.
Click Add a number.
Choose from one of the following dropdown menu options:
The Add a number modal displays.
All added numbers display in the Numbers page.
Ignore the Emergency calling button at this time. This procedure appears later in this guide.
.pstn.*.twilio.com
.When calls route from the PBX to the Trunk, you may need to refine how the PBX passes call data. Think of this as how you dial different types of phone numbers. Twilio expects phone numbers written in the E.164 international format.
If necessary, log in to the 3CX PBX console for your PBX.
Click Outbound Rules on the left navigation. The Add Outbound Rule page displays.
Follow the 3CX documentation on Outbound rules.
The Outbound rules page lets you transform numbers from one format to the E.164 format. This requires the following changes to phone numbers:
+
then the recipient's country codeClick Save at the top of this screen.
The Outbound Rule page displays.
To create additional rules, click + Add.
The following tables provide examples of dialing rules for certain countries. To create your outgoing rules in the 3CX PBX, use this data.
The Route # fields should be set to the value you gave your Twilio trunk in the Name field.
Verify that you can make calls using the phone number, PBX, and trunk you configured.
https://<YOUR-PBX-HOST>/#/office/event-log
.The following table lists issues that may arise when an outgoing call fails.
Issue | Potential remedy |
---|---|
Someone entered the wrong FQDN for your Twilio trunk Termination SIP. | This FQDN maps to your Twilio trunk. Update the SIP FQDN in your 3CX PBX instance. |
Credentials in your 3CX PBX don't match those set in the Twilio Console. | Update the credentials in your 3CX PBX instance. |
Twilio IP ACL doesn't contain the IP address for your 3CX PBX. | Add 3CX PBX IPv4 address to the IP ACL for your Twilio trunk. |
Carrier blocked call due to your Twilio calling number (or caller ID). | Register your trunk phone number with a registry like Free Caller Registry. |
To test inbound calling, you have two options:
If you inbound test call fails, review the following settings.
sip:
.Unidentified Incoming Call
.Extensions in your PBX can dial out to other callers. They can't receive calls without a Direct Inward Dialing (DID) phone number. To assign DID phone numbers to extensions, perform the following tasks.
To assign extensions, you need to create phone numbers in the Twilio Console, then create DID numbers and users in your 3CX PBX console. Extensions get assigned to a user when you create the user.
If necessary, log in to the 3CX PBX console for your PBX.
Click Voice & Chat on the left navigation.
Click your Twilio trunk.
Click the DID Numbers tab.
Add DID numbers in one of two ways:
To create a contiguous block of numbers, open a support ticket. Ask if a suitable range exists in your desired area code.
To preserve the added DID numbers, click Save in the top navigation bar.
The Voice & Chat page displays with the first three numbers listed in the Information column of your Twilio trunk.
Click Users on the left navigation.
Follow the 3CX PBX documentation to create users and their extensions.
You can't assign DID numbers to non-existent extensions.
During this process, include the following steps:
Click Save at the top of this screen.
The Users page displays.
If you didn't create enough DID phone numbers, create more in the Twilio Console.
Before attempting this procedure, check if your territory supports emergency calling.
To allow emergency calls, you need to add and assign a physical address to each direct inward dial phone number. This directs first responders where they're needed when you need them.
If necessary, log in to your Twilio Console.
Go to the Elastic SIP Trunks page.
Click the link for your desired trunk.
Click Numbers on the left navigation rail.
The Numbers page displays.
To assign an emergency address, click the checkbox to the left of each phone number.
With phone numbers checked, click Configure Emergency Address then Add Emergency Address.
Review the Twilio Inc. Emergency Services Addendum on Accept Terms of Service modal.
Click Accept.
The Add Emergency Address displays.
Click + Create New Address.
If you have an existing address, click Select from my Addresses.
From the Select an Address modal, choose a physical address.
The Numbers page displays. The selected address should display Pending registration in the Emergency Address Status. Activate emergency calling takes a few minutes. After 10 to 15 minutes, refresh this page until Registered displays next to the desired phone number.
To learn more, consult the Emergency Calling guide.
Emergency calling requires setting up the emergency numbers in the 3CX PBX. Your PBX needs to call the correct service in the correct locality. The following steps outline how to add emergency numbers.
This works like configuring the dial plan.
To configure emergency calling for the US and Canada, apply these settings.
Rule Name | Number |
---|---|
Emergency Test | 933 |
Emergency | 911 |
Every extension that might call emergency services must have a linked DID number. This DID number must have:
If you succeeded in configuring emergency calling, the expected workflow follows these steps:
If you need to notify security staff in emergencies, 3CX includes notification settings.
US or Canada developers can test their emergency service configuration.
933
.