Friday, December 07, 2007

My stdexten macro

I always forget this so I figure I will post it and update it when I improve it.
[macro-stdexten]
;ARG1 = Device(s) to ring (Default SIP/${MACRO_EXTEN}
;ARG2 = Voicemail Box to go to (Default ${MACRO_EXTEN}
;ARG3 = Timeout in seconds (divide be 5 for number of rings) default 20

exten => s,1,NoOp
exten => s,n,Set(DIALSTRING=${IF($[ "${ARG1}" = "" ]?SIP/${MACRO_EXTEN}:${ARG1})})
exten => s,n,Set(VMAILBOX=${IF($[ "${ARG2}" = "" ]?${MACRO_EXTEN}:${ARG2})})
exten => s,n,Set(TIMEOUT=${IF($[ "${ARG3}" = "" ]?20:${ARG3})})
exten => s,n,Dial(${DIALSTRING},${TIMEOUT},twk)
exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s-,1,Goto(s-BUSY,1)
exten => _s-.,1,Goto(s-BUSY,1)
exten => s-CONGESTION,1,Goto(s-BUSY,1)

exten => s-BUSY,1,Voicemail(${VMAILBOX}@default,b)
exten => s-BUSY,n,Hangup()

exten => s-CHANUNAVAIL,1,Goto(s-NOANSWER,1)

exten => s-NOANSWER,1,Voicemail(${VMAILBOX}@default,u)
exten => s-NOANSWER,n,Hangup