I´m trying to prepend a 0 to all numbers from inbound calls from a sip trunk.
The trunk is created in the trunk menu, and auto-generates this section in
/etc/asterisk/extensions_additional.conf
[from-trunk-sip-sipgate]
include => from-trunk-sip-sipgate-custom
exten => _.,1,Set(GROUP()=OUT_1)
exten => _.,n,Goto(from-trunk,${EXTEN},1)
If i try to create the from-trunk-sip-sipgate-custom context it gets never used. If i understand it correct the include is only used if the Pattern matching finds no match (German Source: das-asterisk-buch.de)
But is there any possibilty that _. could not match? But even if, in my case it doesn´t, so the include is never used.
So i “recreated” the same context in extensions_custom.conf and modified it there:
[from-trunk-sip-sipgate]
exten => _X.,1,GotoIf($[ "${CALLERID(number)}" = "anonymous" ]?nochange)
exten => _X.,n,Set(CALLERID(all)=0${CALLERID(num)})
exten => _X.,n(nochange),Goto(from-trunk,${EXTEN},1)
This does the job, it prepends a 0 to the callerID but nothing for “anonymous”.
But it works only if i use _X. as pattern matching, if i use _. the default dialplan is used.
Is there a less sketchier solution? I don´t like that it only works because the more specific regexpression is prioritized.