Using FreePBX with SignalWire

Using FreePBX and taking advantage of SignalWire’s disruptive pricing on US and Canadian DIDs and voice minutes is almost too easy.

The goal of this tutorial is to get you up and running quickly.

The following are assumed:

  1. You already have a SignalWire space set up
  2. You have purchased a US/Canadian DID
  3. You have created a SIP endpoint (and set the number purchased above to point to this SIP endpoint in terms of handling voice calls, and for it’s CallerID)

If you need help with any of the above, you can find a basic guide here and our SIP guide here.

There are a couple of settings we need to change on the SIP Endpoint we have created in SignalWire in order to get good interworking with FreePBX:

  • Set Encryption to ‘Required’
  • Disable the Encryption option for AEAD_AES_256_GCM_8 as it is not currently supported by Asterisk and will cause a warning on the Asterisk Command Line (though calls would still work).

With the above in place, having this SignalWire SIP Trunk added and working on FreePBX is done in just a few easy steps.

Adding a PJSIP Trunk

Add a SIP (PJSIP) trunk, and on the ‘General’ tab enter the following:

  • Trunk Name: SignalWire (Can be anything you want)
  • Outbound CallerID: 1-469-FREEPBX (the DID you purchased)

Then, on the "pjsip Settings" tab and the "General" sub-tab, enter the following:

  • Username: freepbx (the name you gave the SIP endpoint)
  • Secret: (the password you gave the SIP endpoint)
  • SIP Server: (your space URI)
  • SIP Server Port: 5060 (standard SIP port)
  • Context: from-signalwire (default is ‘from-pstn’, but you must change it)

As the last step on this screen, on the "PJSIP Settings" tab and the "Advanced" sub-tab, the following three settings:

  • From Domain: (your space URI)
  • From User: freepbx (the name you gave the SIP endpoint)
  • Media Encryption: SRTP via in-SDP (select from drop-down)

That’s it for the Trunk set-up!

Setting up the dial plan

There is a small amount of dialplan script to add (which we will place in a context called "from-signalwire" - remember, we set this in the above steps), in order to extract the dialed number from the SIP Header, before passing the call to FreePBX for normal processing.

We do this by entering the following lines in a file called extensions_custom.conf (which may be empty) using the inbuilt config editor in the Admin menu:

exten => s,1,Set(numb=${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)})
same => n,Goto(from-pstn,${numb:1},1) 

The editor is at Admin > Config Edit > extensions_custom.conf:

Now just set up your inbound routing (the DID will be in the format 19877654321) and your outbound routing as normal.

You should now be able to make outbound calls over your SignalWire SIP trunk. You should of course also be able to accept incoming calls to the number you purchased.