Limit channels to google voice in Asterisk Dial plan
Hi, I had found it extremely hard trying limit outbounds channels in Google Voice since the channels don’t offer counts. So I decided to make it easier for everyone else.
I have done my sample using Global Variables.
exten => h,1,Set(GLOBAL(${thetrunk})=0) ; on hangup mark trunk not in use
exten => h,n,Verbose(0, getting staus Dialstatus ${DIALSTATUS} priority ${goto} ${thetrunk} = ${${thetrunk}} )
exten => _1NXXNXXXXXX,1,Set(GROUP()[email protected])
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “”]?15:)
exten => _1NXXNXXXXXX,15,Set(goto=$[${PRIORITY} + 15]) ; handles prioritys
exten => _1NXXNXXXXXX,n,Set(thetrunk=gv2) ; sets trunk name
exten => _1NXXNXXXXXX,n,GotoIf($[${${thetrunk}} > 0]?${goto}) ; if trunk is in use go to next gv
exten => _1NXXNXXXXXX,n,Set(GLOBAL(${thetrunk})=1) ; trunk is marking inuse
exten => _1NXXNXXXXXX,n,Dial(Motif/[email protected]/${EXTEN}@voice.google.com,,r) ; yay dialing out
exten => _1NXXNXXXXXX,n,Set(GLOBAL(${thetrunk})=0) ; if call failure mark trunk not in use
exten => _1NXXNXXXXXX,n,Verbose(0, getting staus ${DIALSTATUS} );
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “SUCCESS”]?hangup:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “FAILED”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “NOANSWER”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “CANCEL”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “BUSY”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “CONGESTION”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “HANGUP”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “UNKNOWN”]?${goto}:)
exten => _1NXXNXXXXXX,30,Set(goto=$[${PRIORITY} + 20])
exten => _1NXXNXXXXXX,n,Set(thetrunk=gv3)
exten => _1NXXNXXXXXX,n,GotoIf($[${${thetrunk}} > 0]?${goto})
exten => _1NXXNXXXXXX,n,Set(GLOBAL(${thetrunk})=1)
exten => _1NXXNXXXXXX,n,Dial(Motif/gv3/${EXTEN}@voice.google.com,,r)
exten => _1NXXNXXXXXX,n,Set(GLOBAL(${thetrunk})=0)
exten => _1NXXNXXXXXX,n,Verbose(0, getting staus ${DIALSTATUS} );
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “SUCCESS”]?hangup:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “FAILED”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “NOANSWER”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “CANCEL”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “BUSY”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “CONGESTION”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “HANGUP”]?${goto}:)
exten => _1NXXNXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “UNKNOWN”]?${goto}:)
Published on: Mar 03, 2021
No Comments yet! Be the first one to write.