The Standard Context for Local Calls

Standard Contexts

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()

  1. We set the variable vmbx (short for voicemailbox) to the ${EXTEN} dialled.
  2. We dial the Extension
  3. Depending on the status returned from the DIAL command, we perform different tasks.

NOANSWER

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

BUSY

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

CHANUNAVAIL

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()

CATCH ALL

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

Voicemail?

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