Apr 13

This setup will enable per extension CallerID to be sent through your SIP trunk provider. It also enables CID to be passed through the system when a call is forwarded. This allows the receiver of the forwarded call to see the calling parties CID rather than the CID of the trunk or PBX. This setup also circumvents a common problem when a phone is forwarded, wherein all attempted calls to the forwarded extension fail with a ‘604 Does Not Exist Anywhere’ error being returned from the provider.

This has been tested with Cbeyond SIPconnect and Speakeasy SIP Trunking and is likely to work with any provider that uses a BroadWorks platform to deliver SIP trunks. The CID functionality is accomplished by adding a diversion header into the call setup.

First, connect to your PBXinaFlash PBX and edit /etc/asterisk/extensions_override_freepbx.conf using your favorite text editor. (You will most likely want to connect to your PBXinaFlash system via SSH using a client like PuTTY.) The file will probably be empty except for a comment in the first line. Add the following lines to the file (note the changes to the 3rd to the last line below):

include => macro-outbound-callerid-custom
exten => s,1,ExecIf($[“${CALLINGPRES_SV}” != “”],SetCallerPres,${CALLINGPRES_SV})
exten => s,n,ExecIf($[“${REALCALLERIDNUM:1:2}” = “”],Set,REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),GotoIf($[ $[“${REALCALLERIDNUM}” = “”] | $[“${KEEPCID}” != “TRUE”] | $[“${OUTKEEPCID_${ARG1}}” = “on”] ]?normcid)
exten => s,n,GotoIf($[“foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}” = “foo”]?bypass)
exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)})
exten => s,n(bypass),Set(EMERGENCYCID=${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)})
exten => s,n,Set(TRUNKOUTCID=${OUTCID_${ARG1}})
exten => s,n,GotoIf($[ $[“${EMERGENCYROUTE:1:2}” = “”] | $[“${EMERGENCYCID:1:2}” = “”] ]?trunkcid)
exten => s,n,Set(CALLERID(all)=${EMERGENCYCID})
exten => s,n(exit),MacroExit()
exten => s,n(trunkcid),ExecIf($[“${TRUNKOUTCID:1:2}” != “”],Set,CALLERID(all)=${TRUNKOUTCID})
exten => s,n(usercid),ExecIf($[“${USEROUTCID:1:2}” != “”],Set,CALLERID(all)=${USEROUTCID})
exten => s,n(usercid),SIPAddHeader(Diversion: <sip:NPANXXXXXX@provider.domain.or.proxy>;reason=unconditional)
exten => s,n(hidecid),ExecIf($[“${CALLERID(name)}”=”hidden”],SetCallerPres,prohib_passed_screen)
; end of [macro-outbound-callerid]

Next, in the 3rd to the last line, you will need to customize the string that reads ‘<sip:NPANXXXXXX@provider.domain.or.proxy>‘. Replace ‘NPANXXXXXX’ with your main phone number. On Cbeyond, this is also your username. If you are on Cbeyond, replace ‘provider.domain.or.proxy’ with the FQDN of the Cbeyond proxy (will be similar to ‘sipconnect.atl0.cbeyond.net’). If you use Speakeasy, replace ‘provider.domain.or.proxy’ with ‘speakeasy.net’. The resulting line will look similar to the following:

exten => s,n(usercid),SIPAddHeader(Diversion: <sip:4045551212@speakeasy.net>;reason=unconditional)

Assuming you already had a working trunk, no other changes should be necessary, however it is worth checking a couple settings before reloading. With regard to the trunk settings, it is important to ensure that you don’t have a ‘fromuser’ line in peer details section. If you do, simply remove it. Depending on your version of PIAF, you may have a setting for ‘Never override CallerID’. Be sure that this is not checked. Also, it is a good idea to leave the ‘Outbound Caller ID’ blank. On later versions of PIAF, there is a ‘CID Options:’ setting. Set this to ‘Allow any CallerID’

NOTE: Each extension MUST INDIVIDUALLY have an outbound CID specified. Otherwise, the call will get rejected and you will get a “all circuits busy” message when attempting to make a call.

Reload PIAF and give it a try!

2 Responses to “How to enable per extension CallerID in PBXinaFlash (PIAF) with Cbeyond and Speakeasy”

  1. thekingmind says:

    Excellent post. This works perfectly with SpeakEasy. However, there is one thing that you may want to add:

    Each extension MUST INDIVIDUALLY have an outbound CID specified. Otherwise, the call will get rejected and you will get a “all circuits busy” message when attempting to make a call.

  2. agatewood says:

    Thanks for the input! I have updated the post.

preload preload preload