<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=426590822-16052005><FONT face=Arial size=2>My dial plan seems
to work great - in that when I call extensions 1234 it connects to 1234.
Strangely, after the call terminates (the other side hangs up first), Asterisk
continues in the same context and then matches to extensions _. which causes an
invalid extension error!</FONT></SPAN></DIV>
<DIV><SPAN class=426590822-16052005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=426590822-16052005><FONT face=Arial size=2>Why does asterisk
not leave the context (called internalmenu) after the remote hangup?
Instead, it continues to the InternalInvalid context (included later in the
InternalMenu context). I'm confused!</FONT></SPAN></DIV>
<DIV><SPAN class=426590822-16052005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=426590822-16052005><FONT face=Arial size=2>Here is a snippet of
the relevant context and macro. Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=426590822-16052005><FONT face=Arial
size=2>Mike</FONT></SPAN></DIV><SPAN class=426590822-16052005><FONT face=Arial
size=2>
<DIV> </DIV>
<DIV><BR>;****************************************************************<BR>;
Macros<BR>;****************************************************************</DIV>
<DIV> </DIV>
<DIV>[macro-stdexten]<BR>;<BR>; Standard extension macro:<BR>;
${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as
well<BR>; ${ARG2} - Device(s) to ring<BR>;<BR>exten =>
s,1,Playback(transfer,skip) ; "Please hold while..." but skip if
channel is not up<BR>;exten => s,2,SendText('Calling extension
'${ARG1}) ; Tell the user what extension being called<BR>exten =>
s,2,SetVar(LastStatus=CallDone) ; Ensure script knows that a Dial was
completed<BR>exten => s,3,Dial(${ARG2},${RINGTIME},r) ; Ring the
interface, 20 seconds maximum<BR>exten =>
s,4,NoOp(${DIALSTATUS}) ; Show status after hangup<BR>exten =>
s,5,Goto(s-${DIALSTATUS},1) ; Jump based on status
(NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)</DIV>
<DIV> </DIV>
<DIV>exten => s-NOANSWER,1,Voicemail(u${ARG1}) ; If unavailable, send to
voicemail w/ unavail announce</DIV>
<DIV> </DIV>
<DIV>exten => s-BUSY,1,Voicemail(b${ARG1}) ; If busy, send to
voicemail w/ busy announce</DIV>
<DIV> </DIV>
<DIV>exten => s-ANSWER,1,NoOp ; If call answered, then do
nothing after hangup</DIV>
<DIV> </DIV>
<DIV>exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as
no answer</DIV>
<DIV> </DIV>
<DIV>exten => a,1,VoicemailMain(${ARG1}) ; If they press *, send
the user into VoicemailMain</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>;****************************************************************<BR>;
Extensions available to all
callers<BR>;****************************************************************<BR>[default]</DIV>
<DIV> </DIV>
<DIV>; Local extensions begin with 2XXX<BR>exten =>
${EXT_MIKE},1,Macro(stdexten,${EXTEN},${CON_MIKE}) ; Mike Stahl
extension<BR>exten =>
${EXT_SPA1},1,Macro(stdexten,${EXTEN},${CON_SPA1}) ; SPA line 1
extension<BR>exten =>
${EXT_SPA2},1,Macro(stdexten,${EXTEN},${CON_SPA2}) ; SPA line 2
extension<BR>exten =>
${EXT_DIANA},1,Macro(fakeexten,${EXTEN},${CON_DIANA}) ; Diana Stahl
extension<BR>exten =>
${EXT_KLAUS},1,Macro(stdexten,${EXTEN},${CON_KLAUS}) ; Klaus Stahl
extension<BR>exten =>
${EXT_BOB},1,Macro(fakeexten,${EXTEN},${CON_BOB}) ; Bob Stahl
extension<BR>exten =>
${EXT_BILL},1,Macro(fakeexten,${EXTEN},${CON_BILL}) ; Bill Stahl
extension</DIV>
<DIV> </DIV>
<DIV>; Direct into voicemail system<BR>exten =>
${EXT_VOICEMAIL},1,VoicemailMain<BR>exten => ${EXT_VOICEMAIL},2,Hangup</DIV>
<DIV> </DIV>
<DIV>; Dial by name<BR>exten => 1,1,Directory(default) ;
Send user to the directory</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>;****************************************************************<BR>; Menu
available to internal callers - full
access<BR>;****************************************************************<BR>[menuinternal]</DIV>
<DIV> </DIV>
<DIV>include => fwd ; Allow outbound access on
FWD using 8 prefix<BR>include => trunkfullaccess ; Allow
full access to external line(s)<BR>include =>
default ; Allow access to all extensions</DIV>
<DIV> </DIV>
<DIV>; Administration menu<BR>exten =>
${EXT_ADMIN},1,Goto(menuadmin,s,1)</DIV>
<DIV> </DIV>
<DIV>; After a message left, offer instruction what to do.<BR>; This menu is
never reached INITIALLY if a specific extension is entered<BR>exten =>
s,1,GotoIf($["${LastStatus}" != "CallDone"] & $["${LastStatus}" !=
""]?4) <BR>exten =>
s,2,SetVar(LastStatus=Try1)<BR>exten => s,3,Goto(11)<BR>exten =>
s,4,GotoIf($["${LastStatus}" !=
"Try1"]?10) <BR>exten =>
s,5,SetVar(LastStatus=UserIdle)<BR>exten => s,6,Goto(11)<BR>exten =>
s,7,GotoIf($["${LastStatus}" !=
"InvalidExtension"]?13)
<BR>exten => s,8,SetVar(LastStatus=UserInvalid)<BR>exten =>
s,9,Goto(11)<BR>exten => s,10,SetVar(LastStatus=Error)<BR>exten =>
s,11,Background(ocg/enterextension) ; PLAY enter the extension you wish to
dial </DIV>
<DIV> </DIV>
<DIV>; "*" Repeat the previous menu<BR>exten => *,1,Goto(s,1)</DIV>
<DIV> </DIV>
<DIV>; "#" hangup <BR>exten =>
#,1,Goto(internalendcall,s,1) ; End the call</DIV>
<DIV> </DIV>
<DIV>; If any other extension then say invalid (used only for initial connection
to allow connection<BR>; instead of 403 error)<BR>include =>
internalinvalid</DIV>
<DIV> </DIV>
<DIV>; If they take too long, check if completed something useful (LastStatus)
go back to menu, else timeout<BR>exten => t,1,GotoIf($["${LastStatus}" =
"UserIdle"] | $["${LastStatus}" = "UserInvalid"] | $["${LastStatus}" =
"Error"]?internalendcall,s,1)
<BR>exten => t,2,Wait(RepeatMenuWaitTime) ; Wait for seconds
before playing menu after last command/event<BR>exten =>
t,3,Goto(s,1) ; Go back to the main menu and repeat
prompt</DIV>
<DIV> </DIV>
<DIV>; If they enter an invalid extension. Should only get here from
_.,1<BR>exten => i,1,SetVar(LastStatus=InvalidExtension)<BR>exten =>
i,2,Background(pbx-invalid) ; "That's not valid, try again"
<BR>exten => i,3,Wait(1) <BR>exten => i,4,Goto(s,1) </DIV>
<DIV> </DIV>
<DIV>; timeout overall<BR>exten => T,1,Goto(internalendcall,s,1)</DIV>
<DIV> </DIV>
<DIV>[internalinvalid]<BR>; This must be in a macro to ensure proper order of
execution<BR>exten => _.,1,GotoIf($["${LastStatus}" =
"CallDone"]?internalmenu,t,2) ; For some reason drop here after call
done<BR>exten => _.,2,goto(menuinternal,i,1) ; Why do we go here
after last extensinon called hangup / noanswer</DIV>
<DIV> </DIV>
<DIV>[internalendcall]<BR>; End the call to the internal user<BR>exten =>
s,1,Playback(vm-goodbye)<BR>exten => s,2,hangup</DIV>
<DIV></FONT></SPAN> </DIV></BODY></HTML>