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!
 
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!
 
Here is a snippet of the relevant context and macro.  Thanks,
Mike
 

;****************************************************************
; Macros
;****************************************************************
 
[macro-stdexten]
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;
exten => s,1,Playback(transfer,skip)  ; "Please hold while..." but skip if channel is not up
;exten => s,2,SendText('Calling extension '${ARG1}) ; Tell the user what extension being called
exten => s,2,SetVar(LastStatus=CallDone) ; Ensure script knows that a Dial was completed
exten => s,3,Dial(${ARG2},${RINGTIME},r) ; Ring the interface, 20 seconds maximum
exten => s,4,NoOp(${DIALSTATUS})  ; Show status after hangup
exten => s,5,Goto(s-${DIALSTATUS},1)  ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
 
exten => s-NOANSWER,1,Voicemail(u${ARG1}) ; If unavailable, send to voicemail w/ unavail announce
 
exten => s-BUSY,1,Voicemail(b${ARG1})  ; If busy, send to voicemail w/ busy announce
 
exten => s-ANSWER,1,NoOp   ; If call answered, then do nothing after hangup
 
exten => _s-.,1,Goto(s-NOANSWER,1)  ; Treat anything else as no answer
 
exten => a,1,VoicemailMain(${ARG1})  ; If they press *, send the user into VoicemailMain
 
 
 
 
;****************************************************************
; Extensions available to all callers
;****************************************************************
[default]
 
; Local extensions begin with 2XXX
exten => ${EXT_MIKE},1,Macro(stdexten,${EXTEN},${CON_MIKE})  ; Mike Stahl extension
exten => ${EXT_SPA1},1,Macro(stdexten,${EXTEN},${CON_SPA1})  ; SPA line 1 extension
exten => ${EXT_SPA2},1,Macro(stdexten,${EXTEN},${CON_SPA2})  ; SPA line 2 extension
exten => ${EXT_DIANA},1,Macro(fakeexten,${EXTEN},${CON_DIANA})  ; Diana Stahl extension
exten => ${EXT_KLAUS},1,Macro(stdexten,${EXTEN},${CON_KLAUS})  ; Klaus Stahl extension
exten => ${EXT_BOB},1,Macro(fakeexten,${EXTEN},${CON_BOB})  ; Bob Stahl extension
exten => ${EXT_BILL},1,Macro(fakeexten,${EXTEN},${CON_BILL})  ; Bill Stahl extension
 
; Direct into voicemail system
exten => ${EXT_VOICEMAIL},1,VoicemailMain
exten => ${EXT_VOICEMAIL},2,Hangup
 
; Dial by name
exten => 1,1,Directory(default)   ; Send user to the directory
 
 
 
;****************************************************************
; Menu available to internal callers - full access
;****************************************************************
[menuinternal]
 
include => fwd     ; Allow outbound access on FWD using 8 prefix
include => trunkfullaccess   ; Allow full access to external line(s)
include => default    ; Allow access to all extensions
 
; Administration menu
exten => ${EXT_ADMIN},1,Goto(menuadmin,s,1)
 
; After a message left, offer instruction what to do.
; This menu is never reached INITIALLY if a specific extension is entered
exten => s,1,GotoIf($["${LastStatus}" != "CallDone"] & $["${LastStatus}" != ""]?4)        
exten => s,2,SetVar(LastStatus=Try1)
exten => s,3,Goto(11)
exten => s,4,GotoIf($["${LastStatus}" != "Try1"]?10)        
exten => s,5,SetVar(LastStatus=UserIdle)
exten => s,6,Goto(11)
exten => s,7,GotoIf($["${LastStatus}" != "InvalidExtension"]?13)        
exten => s,8,SetVar(LastStatus=UserInvalid)
exten => s,9,Goto(11)
exten => s,10,SetVar(LastStatus=Error)
exten => s,11,Background(ocg/enterextension) ; PLAY enter the extension you wish to dial
 
; "*" Repeat the previous menu
exten => *,1,Goto(s,1)
 
; "#" hangup
exten => #,1,Goto(internalendcall,s,1)   ; End the call
 
; If any other extension then say invalid (used only for initial connection to allow connection
; instead of 403 error)
include => internalinvalid
 
; If they take too long, check if completed something useful (LastStatus) go back to menu, else timeout
exten => t,1,GotoIf($["${LastStatus}" = "UserIdle"] | $["${LastStatus}" = "UserInvalid"] | $["${LastStatus}" = "Error"]?internalendcall,s,1)        
exten => t,2,Wait(RepeatMenuWaitTime)  ; Wait for seconds before playing menu after  last command/event
exten => t,3,Goto(s,1)    ; Go back to the main menu and repeat prompt
 
; If they enter an invalid extension.  Should only get here from _.,1
exten => i,1,SetVar(LastStatus=InvalidExtension)
exten => i,2,Background(pbx-invalid)   ; "That's not valid, try again"
exten => i,3,Wait(1)
exten => i,4,Goto(s,1)
 
; timeout overall
exten => T,1,Goto(internalendcall,s,1)
 
[internalinvalid]
; This must be in a macro to ensure proper order of execution
exten => _.,1,GotoIf($["${LastStatus}" = "CallDone"]?internalmenu,t,2)   ; For some reason drop here after call done
exten => _.,2,goto(menuinternal,i,1)  ; Why do we go here after last extensinon called hangup / noanswer
 
[internalendcall]
; End the call to the internal user
exten => s,1,Playback(vm-goodbye)
exten => s,2,hangup
 
_______________________________________________
Asterisk-Users mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to