For a long time I have used Broadvoice for my VoIP provider, this is soon to change (more on this later). Before I lose some nice tricks I have come across with them, I wanted to share them so others could benefit from my hours of time trying to figure it out.
With BroadVoice you have typically have a single ‘line’ with a number attached to it. You then have the option to have alternate numbers added to the line so that you can have more than one phone number. The problem with this is that BroadVoice doesn’t exactly handle them like DID as most VoIP providers do in their services. Therefore it becomes very difficult to route calls or know which number the call actually came in on because you could have up to 4 phone numbers on a single ‘line’ from BroadVoice.
With my own ignorance when I was first working with SIP / VoIP, I ended up with 3 lines from BroadVoice, each with a few numbers on them because they were available and seemed cheap ($1.95 per month per alternate number after $9.95 activation). Due to the lack of correct DID support and 3 lines coming in with a multitude of possible numbers it became very difficult to break numbers out into their own call patterns. By using built-in features of FreePBX and some custom Asterisk code, I was able to break out each number into its own call pattern. I have included the code here for my own reference and the benefit of anyone else who may be in a similar situation.
FreePBX Requirements
- Custom Destinations Module
- Trunks Configured for Each BroadVoice line (Or any SIP trunk with distintive Ring Support)
Trunk Details
- Line 1 – Main Number – 0004, Alt Numbers – 0006
- Line 2 – Main Number – 0003, Alt Numbers – 0000, 0001, 0002
- Line 3 – Main Number – 0005, Alt Numbers  – 0008, 0009
- (Last 4 Digits shown only, actual numbers omitted for security, but yes I almost have 0-9 of a sequence)
Configuration Steps:
- Install Custom Destinations Module in FreePBX
- Create a custom destination for each BroadVoice Line (Ex: Description – BV-Line1, Custom Destination – custom-bv-incoming,s,1)
- Configure Incoming Routes for EACH Broadvoice Line – using Primary number on line in DID with ANY for CID, set destination to matching Custom Destination created
- Create Macros in extensions_custom.conf as shown below – ;drX is the distinctive ring coming from Broadvoice, I commented out the mappings in the file to help with programming.
- Create Incoming Routes for EACH alternate number using the new custom DID defined in the macros – i.e. bv-line2-03, bv-main04 – route to any call destination as desired
- Begin testing! I highly recommend watching the Asterisk debug messages through ‘asterisk -vr’ on command line
Macros Placed in extensions_custom.conf
[custom-bv-incoming]
exten => s,1,Set(foo=${SIP_HEADER(Alert-Info)})
exten => s,2,GotoIf($["${foo}" = ""]?5:3)
exten => s,3,GotoIf($["${foo}" = "<http://127.0.0.1/Bellcore-dr4>"]?8:4)
exten => s,4,GotoIf($["${foo}" = "<http://127.0.0.1/Bellcore-dr3>"]?11:14)
exten => s,5,Set(CALLERID(name)=2424 - ${CALLERID(name)})
exten => s,6,NoOp(${CALLERID(all)})
exten => s,7,Goto(from-pstn,bv-main04,2)
exten => s,8,Set(CALLERID(name)=0007 - ${CALLERID(name)})
exten => s,9,NoOp(${CALLERID(all)})
exten => s,10,Goto(from-pstn,bv-main07,2)
exten => s,11,Set(CALLERID(name)=0006 - ${CALLERID(name)})
exten => s,12,NoOp(${CALLERID(all)})
exten => s,13,Goto(from-pstn,bv-main06,2)
exten => s,14,Set(CALLERID(name)=0010 - ${CALLERID(name)})
exten => s,15,NoOp(${CALLERID(all)})
exten => s,16,Goto(from-pstn,bv-main10,2)
;dr1 = 0004
;dr2 = 0010
;dr3 = 0006
;dr4 = 0007
[custom-bv-line2-incoming]
exten => s,1,Set(foo=${SIP_HEADER(Alert-Info)})
exten => s,2,GotoIf($["${foo}" = ""]?5:3)
exten => s,3,GotoIf($["${foo}" = "<http://127.0.0.1/Bellcore-dr4>"]?8:4)
exten => s,4,GotoIf($["${foo}" = "<http://127.0.0.1/Bellcore-dr3>"]?11:14)
exten => s,5,Set(CALLERID(name)=0003 - ${CALLERID(name)})
exten => s,6,NoOp(${CALLERID(all)})
exten => s,7,Goto(from-pstn,bv-line2-03,2)
exten => s,8,Set(CALLERID(name)=0002 - ${CALLERID(name)})
exten => s,9,NoOp(${CALLERID(all)})
exten => s,10,Goto(from-pstn,bv-line2-02,2)
exten => s,11,Set(CALLERID(name)=0001 - ${CALLERID(name)})
exten => s,12,NoOp(${CALLERID(all)})
exten => s,13,Goto(from-pstn,bv-line2-01,2)
exten => s,14,Set(CALLERID(name)=0000 - ${CALLERID(name)})
exten => s,15,NoOp(${CALLERID(all)})
exten => s,16,Goto(from-pstn,bv-line2-00,2)
;dr1 = 0003
;dr2 = 0000
;dr3 = 0001
;dr4 = 0002
[custom-bv-line3-incoming]
exten => s,1,Set(foo=${SIP_HEADER(Alert-Info)})
exten => s,2,GotoIf($["${foo}" = ""]?5:3)
exten => s,3,GotoIf($["${foo}" = "<http://127.0.0.1/Bellcore-dr4>"]?8:4)
exten => s,4,GotoIf($["${foo}" = "<http://127.0.0.1/Bellcore-dr3>"]?11:14)
exten => s,5,Set(CALLERID(name)=0005 - ${CALLERID(name)})
exten => s,6,NoOp(${CALLERID(all)})
exten => s,7,Goto(from-pstn,bv-line3-05,2)
exten => s,8,Set(CALLERID(name)=0009 - ${CALLERID(name)})
exten => s,9,NoOp(${CALLERID(all)})
exten => s,10,Goto(from-pstn,bv-line3-09,2)
exten => s,11,Set(CALLERID(name)=0008 - ${CALLERID(name)})
exten => s,12,NoOp(${CALLERID(all)})
exten => s,13,Goto(from-pstn,bv-line3-08,2)
exten => s,14,Set(CALLERID(name)=Avail - ${CALLERID(name)})
exten => s,15,NoOp(${CALLERID(all)})
exten => s,16,Goto(from-pstn,bv-Avail,2)
;dr1 = 0005
;dr2 = Available
;dr3 = 0008
;dr4 = 0009