Change inbound callerID conditionally

Hi Guys,

I’m going crazy over this, I have a custom context for my trunk which is working fine.
It strips off the country code for calls from my country, removes the plus for international calls and adds one or two zero’s.
However if a call comes in as anonymous is results in 0anonymous.
I tried several approaches but none of them worked for all cases.
Can anyone point me in the right direction here? Tnx!

  1. Show us your custom context, so we can work with what you already have.
  2. You did not tell us what you want to do with the anonymous calls.

Good point!
I want to leave the anonymous callerid as is instead of adding the zero unintentionally.

exten => _X.,1,NOOP("Entered [mod-CID]")
exten => _X.,n,ExecIf($[ "${CALLERID(num):0:3}" = "+31" ]?Set(CALLERID(num)=${CALLERID(num):3}))
exten => _X.,n,ExecIf($[ "${CALLERID(num):0:1}" = "+" ]?Set(CALLERID(num)=0${CALLERID(num):1}))
exten => _X.,n,Set(CALLERID(num)=0${CALLERID(num)})
exten => _X.,n,goto(from-trunk,${EXTEN},1)

Something like this, it will only pre-pend a 0 to all numeric CID:

exten => _X.,n,ExecIf($["${FILTER(0123456789,${CALLERID(number)})}"="${CALLERID(number)}"]?Set(CALLERID(num)=0${CALLERID(num)}))

I didn’t test, the brackets might be messed up.

Seems to work just fine without any further modification!
Didn’t know about the filter, just what I needed, thanks.

1 Like

IMO, if the intent is to replace +31 with 0 and + with 00, it would be clearer and simpler to do that directly. Or, did I miss something?

exten => _X.,1,NOOP("Entered [mod-CID]")
exten => _X.,n,ExecIf($[ "${CALLERID(num):0:3}" = "+31" ]?Set(CALLERID(num)=0${CALLERID(num):3}))
exten => _X.,n,ExecIf($[ "${CALLERID(num):0:1}" = "+" ]?Set(CALLERID(num)=00${CALLERID(num):1}))
exten => _X.,n,goto(from-trunk,${EXTEN},1)

However, take a look at the incoming INVITE on an anonymous call. Your trunking provider may put the actual calling number in a P-Asserted-Identity or a Remote-Party-ID header. If so, you could extract the number from there and populate CALLERID(num). I have a few (misguided) friends and relatives who block their outbound caller ID by default. This allows them to call without being subjected to my spam filter.

You are right Stewart1. Would be clearer!
I did some testing and ended up with the config posted above but now that it’s working I can clean it up.
Will have a look at the headers but I doubt it, I think the anonymous calls are ‘truly’ anonymous.

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