[general]
static=yes
writeprotect=no
clearglobalvars=no
[globals]
include => parkedcalls

[macro-stdexten];
exten => s,1,Dial(${ARG2},20)			; Ring the interface, 20 seconds maximum
exten => s,2,Goto(s-${DIALSTATUS},1)		; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

exten => s-NOANSWER,1,Voicemail(${ARG1},u)	; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)		; If they press #, return to start

exten => s-BUSY,1,Voicemail(${ARG1},b)		; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)		; If they press #, return to start

exten => _s-.,1,Goto(s-NOANSWER,1)		; Treat anything else as no answer

exten => a,1,VoicemailMain(${ARG1})		; If they press *, send the user into VoicemailMain

[default]

ignorepat => 9

exten => 104,1,Macro(stdexten,104,Zap/4)
exten => 106,1,Macro(stdexten,106,Zap/6)
exten => 107,1,Macro(stdexten,107,Zap/7)
exten => 108,1,Macro(stdexten,108,Zap/8)

; fax machine @ 105
exten => 105,1,Macro(faxexten,105,Zap/5)

; voicemail access
exten => 8500,1,VoicemailMain(${CALLERID(num)})
exten => 8500,n,Hangup
exten => 8501,1,VoicemailMain
exten => 8501,n,Hangup

; outbound long distance, local, and international
exten => _91NXXNXXXXXX,1,Set(CALLERID(num)=5102505025)
exten => _91NXXNXXXXXX,n,Set(CALLERID(name)="Unplugged, Inc.")
exten => _91NXXNXXXXXX,n,Dial(SIP/${EXTEN:1}@vitel-outbound)
exten => _9NXXXXXX,1,Set(CALLERID(num)=5102505025)
exten => _9NXXXXXX,n,Set(CALLERID(name)="Unplugged, Inc.")
exten => _9NXXXXXX,n,Dial(SIP/1510${EXTEN:1}@vitel-outbound)
exten => _9011.,1,Set(CALLERID(num)=5102505025)
exten => _9011.,n,Set(CALLERID(name)="Unplugged, Inc.")
exten => _9011.,n,Dial(SIP/${EXTEN:1}@vitel-outbound)

; 911 to berkeley pd
exten => _911,1,Set(CALLERID(num)=5102505025)
exten => _911,n,Set(CALLERID(name)="Unplugged, Inc.")
exten => _911,n,Dial(SIP/15109815911@vitel-outbound)

; phone programming contexts
exten => 6666,1,ADSIProg(asterisk.adsi)
exten => 6666,2,Hangup
exten => 6667,1,ADSIProg(asterisk.adsi2)
exten => 6667,2,Hangup

; autoattendent
exten => 100,1,GoTo(MainMenu,s,1)
exten => 100,2,Hangup

; recording context
exten => 205,1,Wait(2)
exten => 205,2,Record(/tmp/asterisk-recording:gsm)
exten => 205,3,Wait(2)
exten => 205,4,Playback(/tmp/asterisk-recording)
exten => 205,5,Wait(2)
exten => 205,6,Hangup

[incoming-pots]
exten => s,1,Set(CALLERID(num)=91${CALLERID(num)})
exten => s,n,GoTo(MainMenu,s,1)
exten => s,n,Hangup

[MainMenu]
exten => s,1,Answer                     ; answer call
exten => s,2,Wait(1)                    ; wait 1 sec for line to settle
exten => s,3,Set(TIMEOUT(digit)=5)      ; max 5 secs between digits
exten => s,4,Set(TIMEOUT(response)=15)  ; max 15 secs to input number
exten => s,5,Background(aa-welcome)     ; general welcome message
exten => s,6,Set(TIMEOUT(response)=15)  ; reset response timer
exten => s,7,Background(aa-select)      ; main choices
exten => s,8,WaitExten(15)              ; silence waiting for input
exten => s,9,Playback(aa-goodbye)      ; goodbye
exten => s,10,Hangup                    ; hangup

; jump to extensions
exten => _1XX,1,GoTo(default,${EXTEN},1)
exten => _1XX,2,Hangup
;exten => _2XX,1,GoTo(default,${EXTEN},1)
;exten => _2XX,2,Hangup

; operator
exten => 0,1,Dial(Zap/4&Zap/6&Zap/7&Zap/8,20)   ; Ring 20 seconds maximum
exten => 0,2,Goto(0-${DIALSTATUS},1)    ; Jump based on status
                                        ; (NOANSWER,BUSY,CHANUNAVAIL,
                                        ; CONGESTION,ANSWER)
exten => _0-.,1,Voicemail(u100)         ; basically on no answer/busy
exten => _0-.,2,Hangup

; Provide a directory of users
exten => #,1,Directory(default) ; Users are listed in the default context of voicemail.conf
exten => #,2,Hangup

; hangup
exten => t,1,GoTo(s,10)

; invalid
exten => i,1,Playback(aa-invalid)
exten => i,2,GoTo(s,6)

; send fax's to the fax machine
exten => fax,1,GoTo(default,105,1)

[outbound]
; for vitelity caller id announce
include => default

[inbound]
;exten => xxxxxxxxxx,1,Answer
exten => xxxxxxxxxx,1,Set(CALLERID(num)=91${CALLERID(num)})
exten => xxxxxxxxxx,n,GoTo(MainMenu,s,1)
exten => xxxxxxxxxx,n,Hangup
