Problems with dialplan

Hey,
how to do that properly?

[phone-is-calling]
exten => _X.,1,Set(TEST=12345)
exten => _X.,n,Goto(test1,${EXTEN},1) ;not working, patterns not allowed in next context
exten => _X.,n,Goto(test2,${EXTEN},1) ;not working, patterns not allowed in next context


[test1]
exten => _XXX.,1,Dial(...)
exten => _XXX.,n,Hangup()


[test2]
exten => _NNN.,1,Dial(...)
exten => _NNN.,n,Hangup()

I think you know what I want to do… (create variable before matching patterns)

Thanks in advance!

There is no attempt to match patterns in this dialplan.

Priority 3 is unreachable because it is preceded by an unconditional Goto, and isn’t the target of a Goto.

OK, this should be better for explaining:

[phone-is-calling]
exten => _X.,1,Set(TEST=12345)
include => test1
include => test2

How to set the variable at first?

That’s unusual, but should work as long as there is no exten line in either included file that matches the incoming extension, at priority 1.

I have two phones and I don’t want to match the patterns twice.

Another example:

[phone-is-calling]

exten => 1234,1,Dial(...)
exten => 1234,n,Hangup

exten => 12345,1,Dial(...)
exten => 12345,n,Hangup

exten => 123456,1,Dial(...)
exten => 123456,n,Hangup

How to set a variable before matching patterns? Unhappily it doesn’t work with the s-extension.

I don’t understand why this feature is not possible, is it?

I’m still having problems understanding you, but maybe:

exten=>_X.,1,Set(TEST=1234)

exten=> 1234,2,Dial(....)
same=>n,Hangup ; This line is redundant

exten=>12345,2,Dial(....)
same=>,n,Hangup; Redundant

exten=>123456,2,Dial(.....)
same=>n,Hangup ; Redundant

You can also do:

exten=>_X.,1,Set(TEST=1234)
same=>n,Goto(newcontext,${EXTEN},1)

[newcontext]
exten => 1234,1,Dial(...)
exten => 1234,n,Hangup

exten => 12345,1,Dial(...)
exten => 12345,n,Hangup

exten => 123456,1,Dial(...)
exten => 123456,n,Hangup

PS It would cause less confusion if your examples involved matching a pattern.

But what about patterns in [newcontext]? It didn’t work for me.

Please provide an example that actually contains a pattern, and the contents of the Asterisk log when verbosity is set to at least 5.

None of your examples have contained patterns (except _X.), so we cannot see how you are misusing them.