TIPS Using more than one GVSIP in dialplan

rogerjbos

Member
Joined
Mar 27, 2015
Messages
46
Reaction score
5
I am using two different google voice numbers on the same PBX and wanted to choose which one I use based on extension rather than the number of digits dialed. It took me a while, but I got it working so I thought I would post it in case it helps anyone else. I have two extensions defined, 701 and 1002, so check the extension number and if it is 1002 I dial using gvsip2 and otherwise I dial using gvsip1. You could expand this for any number of google voice lines and you could test for extension ranges. Please let me know if anyone sees something that could be improved.

[from-internal-custom]
;# // BEGIN gvsip outgoing

;exten => _*48NXXNXXXXXX,1,Set(CALLERID(dnid)=${CALLERID(dnid):3})
;exten => _*48NXXNXXXXXX,n,Set(CALLERID(dnid)=1${CALLERID(dnid)})
;exten => _*48NXXNXXXXXX,n,Set(CHANNEL(accountcode)=Google Voice)
;exten => _*48NXXNXXXXXX,n,Dial(PJSIP/1${EXTEN:3}@gvsip1,,r)
;exten => _*481NXXNXXXXXX,1,Set(CALLERID(dnid)=${CALLERID(dnid):4})
;exten => _*481NXXNXXXXXX,n,Set(CALLERID(dnid)=1${CALLERID(dnid)})
;exten => _*481NXXNXXXXXX,n,Set(CHANNEL(accountcode)=Google Voice)
;exten => _*481NXXNXXXXXX,n,Dial(PJSIP/1${EXTEN:4}@gvsip2,,r)

; To use no *48 dial prefix, comment out lines above and uncomment lines below
;exten => _NXXNXXXXXX,1,Set(CALLERID(dnid)=${CALLERID(dnid)})
;exten => _NXXNXXXXXX,n,Set(CALLERID(dnid)=1${CALLERID(dnid)})
;exten => _NXXNXXXXXX,n,Set(CHANNEL(accountcode)=Google Voice)
;exten => _NXXNXXXXXX,n,Dial(PJSIP/1${EXTEN}@gvsip1,,r)
;exten => _1NXXNXXXXXX,1,Set(CHANNEL(accountcode)=Google Voice)
;exten => _1NXXNXXXXXX,n,Dial(PJSIP/1${EXTEN:1}@gvsip2,,r)

; this is working for 10 digits
exten => _NXXNXXXXXX,1,Set(CALLERID(dnid)=${CALLERID(dnid)})
same => n,Set(CALLERID(dnid)=1${CALLERID(dnid)})
same => n,Set(CHANNEL(accountcode)=Google Voice)
same => n,GotoIf($[${CALLERID(num)}=1002]?GV2)
same => n,Verbose(Using GV1)
same => n,Dial(PJSIP/1${EXTEN}@gvsip1,,r)
same => n,hangup
same => n(GV2),Verbose(Using GV2)
same => n,Dial(PJSIP/1${EXTEN}@gvsip2,,r)
same => n,hangup

; and this is working for 11 digits
exten => _1NXXNXXXXXX,1,GotoIf($[${CALLERID(num)}=1002]?GV2)
same => n,Verbose(Using GV1)
same => n,Dial(PJSIP/1${EXTEN:1}@gvsip1,,r)
same => n,hangup
same => n(GV2),Verbose(Using GV2)
same => n,Dial(PJSIP/1${EXTEN:1}@gvsip2,,r)
same => n,hangup

;# // END gvsip outgoing
 

rogerjbos

Member
Joined
Mar 27, 2015
Messages
46
Reaction score
5
To follow up on my post above, if you upgrade as mentioned here:

Incoming calls now are handled in the FreePBX GUI using your GVSIP custom trunk. See the new build under this thread for the latest implementation which relies entirely on FreePBX.

and you want to dial out without using a prefix to choose a trunk, you can choose your trunk via the outbound call routing. For example, if you create two outbound routes called GV1 and GV2 and you want extension 701 to call out using GV1 and extensions 1000 to 1099 to call out using GV2, then the "dial pattern" for GV1 would be ( ) | [ 1NXXNXXXXXX / 701 ] and the "dial pattern" for GV2 would be () | [ 1NXXNXXXXXX / 10XX ]. What I found was that I had to put the extension (the part after the / ) in both of the routes. Putting the extension in only one didn't work. That is my "tip" to you, I hope it helps someone. Young people today may be okay with dialing prefixes, but when you set up a phone for your mother in law, you don't want her to have to dial a prefix to call out!
 

Members online

Forum statistics

Threads
25,778
Messages
167,504
Members
19,198
Latest member
serhii
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top