;
; extensions.conf - the Asterisk dial plan
;
[general]
static=yes
writeprotect=no
[globals]
DIR_RECORDS=/opt/mnt/calls/
TRANSFER_CONTEXT=local
[default]
[macro-recording]
;exten => s,1,Set(fname=${UNIQUEID}-${STRFTIME(${EPOCH},,%Y-%m-%d-%H_%M)}-${ARG1}-${ARG2});
exten => s,1,Set(fname=${STRFTIME(${EPOCH},,%Y/%m/%d)}/${UNIQUEID}-${STRFTIME(${EPOCH},,%Y-%m-%d-%H_%M)}-${ARG1}-${ARG2});
exten => s,n,Set(monopt=nice -n 19 /usr/local/bin/lame -b 32 --silent "${DIR_RECORDS}${fname}.wav" "${DIR_RECORDS}${fname}.mp3" && rm -f "${DIR_RECORDS}${fname}.wav" && chmod o+r "${DIR_RECORDS}${fname}.mp3");
exten => s,n,Set(CDR(filename)=${fname}.mp3);
exten => s,n,Set(CDR(realdst)=${ARG2});
exten => s,n,MixMonitor(${DIR_RECORDS}${fname}.wav,b,${monopt});
exten => s,n(no),Verbose(Exit record);
[phones]
include => local
include => outgoing
[local]
exten => 900,1,Answer()
exten => 900,n,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 900,n,ConfBridge(1,confer)
exten => 101,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 101,n,Dial(SIP/801&SIP/802,60)
exten => _XXX,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX,n,Dial(SIP/${EXTEN},60,tT)
exten => _XXX,n,Hangup()
exten => _XXX.,1,Goto(outgoing,${EXTEN},1)
[outgoing]
exten => _XXX.,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX.,n,Gosub(trunk_check,s,1(${EXTEN}))
;Dial plan "Incoming"
[incoming]
exten => 213135,1,Goto(ivr-main-1,s,1)
exten => 213136,1,Goto(ivr-main-1,s,1)
exten => 213137,1,Goto(ivr-main-1,s,1)
exten => 213153,1,Goto(ivr-main-1,s,1)
exten => 213157,1,Goto(ivr-main-1,s,1)
exten => 213158,1,Background(/etc/asterisk/ivr/notice_record)
exten => 213158,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 213158,n,Dial(SIP/114,,t)
exten => 213159,1,Background(/etc/asterisk/ivr/notice_record)
exten => 213159,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 213159,n,Dial(SIP/121,,t)
exten => 213162,1,Background(/etc/asterisk/ivr/notice_record)
exten => 213162,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 213162,n,Dial(SIP/102,,t)
[trunk_check]
exten => s,1,Dial(SIP/${ARG1}@213135,45,T)
same => n,Dial(SIP/${ARG1}@213136,45,T)
same => n,Dial(SIP/${ARG1}@213157,45,T)
same => n,Dial(SIP/${ARG1}@213153,45,T)
same => n,Dial(SIP/${ARG1}@213158,45,T)
same => n,Dial(SIP/${ARG1}@213159,45,T)
same => n,Dial(SIP/${ARG1}@213162,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,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX,2,Background(/etc/asterisk/ivr/notice_record)
exten => _XXX,n,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,Background(/etc/asterisk/ivr/notice_record)
exten => t,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => t,n,Dial(SIP/110,15)