[solved] Prepend zero on inbound calls from sip trunk

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

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:

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.

And how do i do that?

In Conectivity / Trunks / my sip Trunk / sip Settings / Incoming
I tried setting USER context to [prepend-zero] and/or writing in USER Details context=prepend-zero
With the same context as above, just with another name, but that didn´t worked

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)

Add the same line to your peer details as well.

This works, i don´t even need to give the context in the incoming section, only this line in the peer details in the outgoing section.

It would have never come to my mind that i have to change settings in the outgoing section for incoming calls :sweat_smile:

Thanks for your help!

1 Like

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