To enhance call management, we use a Subroutine for stdexten to call local extensions (clients.)
The Subroutine accepts one parameter, the extension to dial:
[stdexten]
exten => _X.,1,Set(LOCAL(vmbx)=${EXTEN})
same => n,Dial(SIP/${EXTEN},60) ; Ring the interface, 60 seconds maximum
same => n,Gosub(stdexten-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
same => n,Return()
If the return is NO Answer, pass the call to VoiceMail with the “u” parameter.
exten => stdexten-NOANSWER,1,Voicemail(${vmbx},u) ; If unavailable, send to voicemail w/ unavail announce
same => n,Return() ; If they press #, return to start
If the return is BUSY, pass the call to VoiceMail with the “b” parameter.
exten => stdexten-BUSY,1,Voicemail(${vmbx},b) ; If busy, send to voicemail w/ busy announce
same => n,Return() ; If they press #, return to start
If the extension is not available (e.g. user is not logged in) then tell the user this is not a valid extension (you can of course choose a different behaviour)
exten => stdexten-CHANUNAVAIL,1,Background(invalid)
same => n,Return()
If the response is not known, treat it as NOANSWER.
exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) ; Treat anything else as no answer
exten => a,1,VoicemailMain(${vmbx}) ; If they press *, send the user into VoicemailMain
same => n,Return()
Put together, the Subroutine looks like this:
[stdexten]
exten => _X.,1,Set(LOCAL(vmbx)=${EXTEN})
same => n,Dial(SIP/${EXTEN},60) ; Ring the interface, 60 seconds maximum
same => n,Gosub(stdexten-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
same => n,Return()
exten => stdexten-NOANSWER,1,Voicemail(${vmbx},u) ; If unavailable, send to voicemail w/ unavail announce
same => n,Return() ; If they press #, return to start
exten => stdexten-BUSY,1,Voicemail(${vmbx},b) ; If busy, send to voicemail w/ busy announce
same => n,Return() ; If they press #, return to start
exten => stdexten-CHANUNAVAIL,1,Background(invalid)
same => n,Return()
exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) ; Treat anything else as no answer
exten => a,1,VoicemailMain(${vmbx}) ; If they press *, send the user into VoicemailMain
same => n,Return()
File extract: /etc/asterisk/extensions.conf
[default]
exten => *99,1,VoiceMailMain(${FILTER(0-9,${CALLERID(NUM)})})
exten => _1XX,1,Dial(SIP/${FILTER(0-9,${EXTEN})},12,tr)
same => n,Voicemail(${FILTER(0-9,${EXTEN})})
same => n,Hangup()
The above cut-down version of extensions.conf has 2 basic dial extensions