Very similar to the stock version of standard extension in extensions.conf on Asterisk 11 with some minor customizations to the variables passed to it. Technically, this is not what I’m calling a “module” (which is actually a subroutine), this is just an example of the stdexten context which some may find useful.
In my scenario, under no circumstances would there be any reason to have to change the voicemail context, so the arguments that get passed are: The devices to ring, the timeout period (how long to ring the extension), and the destination voicemail box. If neither of the second and third arguments are passed, then it assumes a timeout period of 25 milliseconds and the extension passed in argument one as the voicemail box.
Here is the stdexten context:
[stdexten] ; Standard extension subroutine: ; ${EXTEN} - Extension ; ${ext} ; ${ARG1} - Device(s) to ring ; ${dst} ; ${ARG2} - Dial Timeout ; ${tmt} 25 seconds ; ${ARG3} - Specify voicemail box to use ; ${mbx} ; Syntax: Gosub(context,extension,priority(${ARG1},${ARG2},${ARG3})) ; Use: Gosub(stdexten,${EXTEN} or specify extension,stdexten(SIP/4000&SIP/4002,25,4000)) exten => _X.,1001(stdexten),NoOp(Dialing standard extension) exten => _X.,n,Set(LOCAL(ext)=${EXTEN}) exten => _X.,n,Set(LOCAL(dst)=${ARG1}) exten => _X.,n,Set(LOCAL(tmt)=${IF($[${ISNULL(${ARG2})} = 1]?25:${ARG2})}) exten => _X.,n,Set(LOCAL(mbx)=${IF($[${ISNULL(${ARG3})} = 1]?${ext}:${ARG3})}) exten => _X.,n,Dial(${dst},${tmt}) exten => _X.,n,Goto(stdexten-${DIALSTATUS},1) exten => stdexten-NOANSWER,1,Voicemail(${mbx},u) exten => stdexten-NOANSWER,n,Return() exten => stdexten-BUSY,1,Voicemail(${mbx},b) exten => stdexten-BUSY,n,Return() exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) exten => a,1,VoicemailMain(${mbx}) exten => a,n,Return()
Here is a simple example of an in house call to stdexten that also incorporates the use of another dialplan module, “sub-GetSourceCID”, to first look up the source caller ID from your Asterisk MySQL database:
exten => _40XX,1,Gosub(sub-GetSourceCID,${EXTEN},1) exten => _40XX,n,Gosub(stdexten,${EXTEN},stdexten(SIP/${EXTEN})) exten => _40XX,n,Hangup()