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:

1 [stdexten]
2 exten => _X.,1,Set(LOCAL(vmbx)=${EXTEN})
3  same => n,Dial(SIP/${EXTEN},60)  ; Ring the interface, 60 seconds maximum
4  same => n,Gosub(stdexten-${DIALSTATUS},1)  ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
5  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.

7 exten => stdexten-NOANSWER,1,Voicemail(${vmbx},u)  ; If unavailable, send to voicemail w/ unavail announce
8  same => n,Return()  ; If they press #, return to start

BUSY

If the return is BUSY, pass the call to VoiceMail with the "b" parameter.

10 exten => stdexten-BUSY,1,Voicemail(${vmbx},b)  ; If busy, send to voicemail w/ busy announce
11  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)

13 exten => stdexten-CHANUNAVAIL,1,Background(invalid)
14  same => n,Return()

CATCH ALL

If the response is not known, treat it as NOANSWER.

16 exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1)  ; Treat anything else as no answer

Voicemail?

18 exten => a,1,VoicemailMain(${vmbx})  ; If they press *, send the user into VoicemailMain
19  same => n,Return()

Put together, the Subroutine looks like this:

 1 [stdexten]
 2 exten => _X.,1,Set(LOCAL(vmbx)=${EXTEN})
 3  same => n,Dial(SIP/${EXTEN},60)  ; Ring the interface, 60 seconds maximum
 4  same => n,Gosub(stdexten-${DIALSTATUS},1)  ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
 5  same => n,Return()
 6 
 7 exten => stdexten-NOANSWER,1,Voicemail(${vmbx},u)  ; If unavailable, send to voicemail w/ unavail announce
 8  same => n,Return()  ; If they press #, return to start
 9 
10 exten => stdexten-BUSY,1,Voicemail(${vmbx},b)  ; If busy, send to voicemail w/ busy announce
11  same => n,Return()  ; If they press #, return to start
12 
13 exten => stdexten-CHANUNAVAIL,1,Background(invalid)
14  same => n,Return()
15 
16 exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1)  ; Treat anything else as no answer
17 
18 exten => a,1,VoicemailMain(${vmbx})  ; If they press *, send the user into VoicemailMain
19  same => n,Return()

File extract: /etc/asterisk/extensions.conf

1 [default]
2 exten => *99,1,VoiceMailMain(${FILTER(0-9,${CALLERID(NUM)})})
3 
4 exten => _1XX,1,Dial(SIP/${FILTER(0-9,${EXTEN})},12,tr)
5  same => n,Voicemail(${FILTER(0-9,${EXTEN})})
6  same => n,Hangup()

The above cut-down version of extensions.conf has 2 basic dial extensions

  • *99 to check voice mail for the extension that called.
  • 1XX. Connect to numbers beginning with "1" and with only 2 additional numbers. If no one answers, leave a voicemail.