[asterisk-users] dialplan goto - bad priority
asterisk at phreaknet.org
asterisk at phreaknet.org
Mon Sep 6 08:52:18 CDT 2021
On 9/6/2021 9:22 AM, marek wrote:
> hi,
>
> i have this dialplan
>
> [incoming]
> exten => _X./_+421XXXXXXXXX,1,noop(cut +421 from CALLER)
> exten => _X./_+421XXXXXXXXX,n,Set(CALLERID(num)=${CALLERID(num):4})
> exten => _X./_+421XXXXXXXXX,n,goto(${CONTEXT},${EXTEN},1)
> exten => _X.,1,noop(main block)
> exten => _X.,n,noop(main block #2)
> exten => _X.,n,Set(GWNAME=out)
>
> my problem is when call arrive with +421 so i want strip this example
> prefix from callerid
>
> then i expecting that call jump(goto) to the line
>
> exten => _X.,1,noop(main block)
>
> but it jumps to
>
> exten => _X.,n,Set(GWNAME=out)
>
> any idea of this behavior?
That is the intended behavior. See
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching#PatternMatching-MatchingonCallerID.
When you change the Caller ID and you are extension pattern matching on
that, the extension immediately changes. Thus, you will advance to the
next priority, but in a different extension. You never hit
goto(${CONTEXT},${EXTEN},1) because as soon as you change the Caller
ID, it's not going to pattern match on that priority anymore. It's going
to fall back to the more general extension match, with the next priority.
A simple way to avoid this might be rewriting using a separate context:
[rewrite-421]
exten => _X!,1,NoOp(cut +421 from CALLER)
same => n,Set(CALLERID(num)=${CALLERID(num):4})
same => n,Goto(incoming,${EXTEN},1)
[incoming]
exten => _X./_+421XXXXXXXXX,1,Goto(rewrite-421,${EXTEN},1)
exten => _X.,1,noop(main block)
exten => _X.,n,noop(main block #2)
exten => _X.,n,Set(GWNAME=out)
More information about the asterisk-users
mailing list