PLIVO to FREEPBX & Asterisk Trunking

Make and receive phone calls on your Asterisk based phone system using Plivo SIP trunks and FREEPBX/AsteriskNow.

 

The important thing to remember is that Heroku or the Endpoint /Trunk apps can be hosted or static XML. Plivo relies on the XML to know what you want it to do.  Plivo DOES NOT send DID over the registration /trunk.

 You've probably used the Plivo Inbound Trunk or Outbound trunk articles.. They only tell part of the story with a little help from Plivo Support we came up with this:

 

 

Plivo Side of the Configuration

 

Step 1. Create Outbound Application.

Screen Shot 2016-01-22 at 3.48.43 PM.pngThe important thing is: http://easytrunk.plivo.com/response/sip/route/?AUTH=SOMESECRETHEREAUTH_USEDINOVERRIDEATBOTTOM

Make Public URI

 

 

Step 2. Create Endpoint.

Choose the Outbound Application from Step 1. Save it.  Hit Plus and the Username and Secret will be used in Freepbx on the registration strings and Trunk tabs below.

 

 

 

 

Screen Shot 2016-01-22 at 3.51.44 PM.pngStep 3. Create Inbound Application.

The important thing is the Answer URI which look like:

http://easytrunk.herokuapp.com/response/sip/inbound_trunk/?DESTINATION=sip:USERNAMEHEREFORYOURENDPOINTPAGE@phone.plivo.com&DialMusic=real&

Step 4. Assign Number to Inbound Application

 

 

 

 

 

 

 

 

FREEPBX Config

 

Create a new SIP TRUNK in Freepbx: 

Screen Shot 2016-01-22 at 4.01.20 PM.pngOutgoing TRUNK NAME:   USERNAMEHEREFORYOURENDPOINTPAGE

username= USERNAMEHEREFORYOURENDPOINTPAGE
secret=SOMESECRETHERE
type=friend
host=phone.plivo.com
context=from-trunk
nat=yes
insecure=very
canreinvite=no
qualify=yes
disallow=all
allow=gsm,ulaw,g722

 

IScreen Shot 2016-01-22 at 4.02.19 PM.pngncoming Tab:

User context: from-trunk

User details: 

type=user
transport=tcp
nat=yes
insecure=very
context=from-trunk
canreinvite=no
qualify=yes
disallow=all
allow=gsm,ulaw,g722

Registration String: USERNAMEHEREFORYOURENDPOINTPAGE:SECRETFORENDPOINT@phone.plivo.com/

 

Override some Headers!

To do outbound calling you need to override some SIP headers. In Freepbx go to Admin -> config edit and choose the extensions_custom.conf file. Put in this file after changing the username, and the SIPURIHEREFROMTHEOUTBOUNDAPPLICATION retrieve from the Plivo Outbound Application SIP URI.

 

 [macro-dialout-trunk-predial-hook]
exten => s,1,Gotoif($["${custom}" != "SIP/USERNAMEHEREFORYOURENDPOINTPAGE"]?600)
exten => s,2,SIPAddHeader(X-PH-destination: ${ARG2})
exten => s,3,SIPAddHeader(X-PH-clid: ${CALLERID(num)})
exten => s,4,SIPAddHeader(X-PH-auth:SOMESECRETHEREAUTH_USEDINOVERRIDEATBOTTOM)
exten => s,5,SIPAddHeader(X-PH-dial_music: real)
exten => s,6,Dial(sip/SIPURIHEREFROMTHEOUTBOUNDAPPLICATION@app.plivo.com, 30)
exten => s,n(600),MacroExit()

 

 

 

For all your IT needs, or if you have questions feel free to get in contact with us!  info@wildcardcorp.com or 715.869.3440!