Monday, June 21, 2010

Improvements to an asterisk dialplan

After using my previously posted solution for a little bit, I've discovered some deficiencies in it.

  • I can't URI dial (in or out)
  • I can't call additional extensions from one extension to another
  • Google Voice voicemail wasn't kicking in
  • I can't 7 digit dial for my local area code
  • Only one extension will ring at a time for incoming calls

So here is an improved dialplan setup, more modular and should be able to account for all of those deficiencies:


New Dialplan

[default]
exten => s,1,GotoIf(${DB_EXISTS(gv_dialout/channel)}?bridged)
exten => s,n,Dial(SIP/101&SIP/102,10)
exten => s,n, Hangup
exten => s,n(bridged),Bridge(${DB_DELETE(gv_dialout/channel)}, p)
exten => 101, 1, Dial(SIP/101, 10)
exten => 102, 1, Dial(SIP/102, 10)


;
; Default starting context for internal SIP devices
;


[outbound]
include => local-devices
include => tollfree
include => gv-outbound
include => dial-uri


;
; These are for any local extensions we should be supporting
;
[local-devices]
exten => _101, 1, Dial(SIP/101,10)
exten => _102, 1, Dial(SIP/102,10)


;
; These are for outbound toll free numbers we support
;


[tollfree]
exten => _411, 1, Dial(SIP/18004664411@proxy.ideasip.com,60)
exten => _1800NXXXXXX,1,Dial(SIP/${EXTEN}@proxy.ideasip.com,60) 
exten => _1888NXXXXXX,1,Dial(SIP/${EXTEN}@proxy.ideasip.com,60) 
exten => _1877NXXXXXX,1,Dial(SIP/${EXTEN}@proxy.ideasip.com,60) 
exten => _1866NXXXXXX,1,Dial(SIP/${EXTEN}@proxy.ideasip.com,60)


;
; Route the call using the google voice bridge
;


[gv-outbound]
;append an area code (512) if necessary
exten => _NXXXXXX,1,Set(CALLERID(dnid)=1512${CALLERID(dnid)})
exten => _NXXXXXX,n,Goto(1512${EXTEN},1)
;append a 1 if necessary
exten => _NXXNXXXXXX,1,Set(CALLERID(dnid)=1${CALLERID(dnid)})
exten => _NXXNXXXXXX,n,Goto(1${EXTEN},1)
;do our real dialing
exten => _1NXXNXXXXXX,1,AGI(google-voice-dialout.agi)
exten => _+1NXXNXXXXXX,1,AGI(google-voice-dialout.agi)




;
; Dialing by SIP URL eg foo@domain.com
;


[dial-uri] 
exten => _[a-z].,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)
exten => _[A-Z].,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)
exten => _X.,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)