Dialplan Extension Sort and Selection

Hello, I am using Asterisk 13 and cannot understand why my dialplan is choosing a pattern over an explicit extension. Can you please look at this and tell me what I need to change?

[internalextensions]

exten => 4030,1,Dial(SIP/operatorone)
 same => n,HangUp()

exten => 3030,1,Goto(internalextensions,4030,1)
 same => n,HangUp()

exten => _3XXX,1,Set(CALLERID(num)=00${CALLERID(num)})
 same => n,Dial(SIP/4${EXTEN}@otherpbx)
 same => n,GotoIf($["${DIALSTATUS}"="CONGESTION"]?OtherRoute)
 same => n,GotoIf($["${DIALSTATUS}"="CHANUNAVAIL"]?OtherRoute:StopTrying)
 same => n(OtherRoute),Dial(SIP/4${EXTEN}@otherpbx2)
 same => n,GotoIf($["${DIALSTATUS}"="CONGESTION"]?Sorry)
 same => n,GotoIf($["${DIALSTATUS}"="CHANUNAVAIL"]?Sorry:StopTrying)
 same => n(Sorry),Playback(sorry-pbx)
 same => n(StopTrying),HangUp()

The command dialplan show 3030@internalextensions shows that the explicit extension 3030 should come first but when I dial this extension from a device in that same context the call follows the _3XXX pattern.

The weird thing is that if I move the patterned extension to appear in the context before the explicit extension it works as I expect it to: Dialling 3030 is pushed to 4030 but dialling a different 3XXX number follows the pattern. In both cases the dialplan show command displays the same order, which is that the explicit extension comes first.

I am not sure, but:

I suspect the extensions are parsed from bottom up.
That’s what you get if you type the command dialplan show internalextensions

1 Like

They will be initially parsed in textual order, but the actual searches will be one on the internal data structure, and should be written to not be sensitive to the order in hash tables etc.

Where I would expect confusion is with the the use of “include =>”.

However, this is all academic, as Asterisk 13 is no longer supported, and it wouldn’t surprise me if the OP isn’t using the final sub-version of Asterisk 13, as many claims are Asterisk 13 are not for the final version.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.