[general]
static=yes
writeprotect=no
[globals]
TRANSFER_CONTEXT=local
[default]
[phones]
include => local
include => outgoing
[local]
exten => 900,1,Answer()
exten => 900,n,ConfBridge(1,confer)
exten => _XXX,1,Dial(SIP/${EXTEN},60,tT)
exten => _XXX,n,Hangup()
[outgoing]
exten => _XXX.,1,Gosub(trunk_check,s,1(${EXTEN}))
;Dial plan "Incoming"
[incoming]
exten => *****35,1,Dial(SIP/150,,t)
exten => *****36,1,Goto(ivr-main-1,s,1)
exten => *****37,1,Dial(SIP/125,,t)
exten => *****53,1,Goto(ivr-main-1,s,1)
exten => *****57,1,Goto(ivr-main-1,s,1)
exten => *****58,1,Dial(SIP/122,,t)
exten => *****59,1,Dial(SIP/145,,t)
exten => *****62,1,Goto(ivr-main-1,s,1)
[trunk_check]
exten => s,1,Dial(SIP/${ARG1}@*****53,45,T)
same => n,Dial(SIP/${ARG1}@*****35,45,T)
same => n,Dial(SIP/${ARG1}@*****36,45,T)
same => n,Dial(SIP/${ARG1}@*****57,45,T)
same => n,Dial(SIP/${ARG1}@*****58,45,T)
same => n,Dial(SIP/${ARG1}@*****59,45,T)
same => n,Dial(SIP/${ARG1}@*****62,45,T)
same => n,Hangup()
[ivr-main-1]
exten => s,1,Answer()
exten => s,2,Background(/etc/asterisk/ivr/ivr-welcome-02)
exten => s,3,WaitExten(5)
exten => _XXX,1,Dial(SIP/${EXTEN},15)
;Check status peer: exists or not
exten => _XXX,n,GotoIf($["${SIPPEER(${EXTEN},status)}" = ""]?num-not-exist,1)
;Check status peer: enable or not
exten => _XXX,n,GotoIf($["${SIPPEER(${EXTEN},status):0:2}" = "UN"]?num-not-connected,1)
;Check channel
exten => _XXX,n,ChanIsAvail(SIP/${EXTEN},s)
;If 2 or 3 - Busy
exten => _XXX,n,GoToIf($[${AVAILSTATUS} = 2]?num-BUSY,1)
exten => _XXX,n,GoToIf($[${AVAILSTATUS} = 3]?num-BUSY,1)
;other statuses
exten => _XXX,n,Goto(num-${DIALSTATUS},1)
;Say - Try again
exten => num-not-exist,1,Wait(2)
exten => num-not-exist,n,Playback(invalid)
;Say - check number
exten => num-not-connected,1,Wait(2)
exten => num-not-connected,n,Playback(ss-noservice)
;Say - Busy
exten => num-BUSY,1,Wait(2)
exten => num-BUSY,n,Playback(vm-isonphone)
;Say - not available
exten => num-NOANSWER,1,Wait(2)
exten => num-NOANSWER,n,Playback(vm-isunavail)
;status CHANUNAVAIL,say - disabled
exten => num-CHANUNAVAIL,1,Wait(2)
exten => num-CHANUNAVAIL,n,Playback(vm-isunavail)
;return Secretariat
exten => t,1,Dial(SIP/101,15)