Stdexten macro
From KlavoWiki
Jump to navigationJump to search
Below is a macro for the purpose of sending calls to. This will call an extension and based on the dial status will handle the call accordingly.
[macro-stdexten]
; Standard extension macro:
; ${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as well - Voicemail Number
; ${ARG2} - Device(s) to ring - Extension Number
exten => s,1,Dial(${ARG2},20,twh) ; 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}@default,usj) ; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,n,Hangup ; If they press #, return to start
exten => s-NOANSWER,102,Playtones(congestion)
exten => s-NOANSWER,n,HangUp
exten => s-BUSY,1,Voicemail(${ARG1}@default,bsj) ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,n,HangUp ; If they press #, return to start
exten => s-BUSY,102,Playtones(congestion)
exten => s-BUSY,n,HangUp
exten => s-CHANUNAVAIL,1,BackGround(pbx-invalid)
exten => s-CHANUNAVAIL,n,BackGround(goodbye)
exten => s-CHANUNAVAIL,n,HangUp
exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer
exten => a,1,VoicemailMain(${ARG1}@default) ; If they press *, send the user into VoicemailMain
exten => a,n,HangUp
A modified version to transfer calls to another phone or extension if the calling extension is in use:
; This code is used for Manager/Secretary Function
exten => s,1,GotoIf($["${ARG1}" = "1209"]?2:8) ; Extension to check
exten => s,n,ChanIsAvail(SIP/1209,s)
exten => s,n,GotoIf($["${AVAILSTATUS}" = "2"]?6:4) ; 2 AST_DEVICE IN USE - "In use"; channel is in use
exten => s,n,GotoIf($["${AVAILSTATUS}" = "3"]?6:5) ; 3 AST_DEVICE_BUSY - "Busy"; channel is busy
exten => s,n,GotoIf($["${AVAILSTATUS}" = "6"]?6:8) ; 6 AST_DEVICE_RINGING - "Ringing"; ring, ring, ring.
exten => s,n,Dial(SIP/1201,20,tw) ; Extension or number to foward to
exten => s,n,Goto(s-NOANSWER,1)