Rewrite Incoming Truck Caller ID

Hi Guys,

Recently, we have begun to use a local incumbent instead of someone more international per se such as Voxbone or BICS so this is the first time I’ve had to deal with this issue type of issue since they aren’t sending Caller ID in E 164 for some reason.

Anyways, how would we rewrite the Caller ID for that specific trunk?

06 (Prefix) - Local Prefix to change it to say E.164 aka +36
00 (International Prefix) - Remove 00 and change it to +

Thank you in advance for your assistance!

You have two choices - the easy way and the hard way. Which is which, unfortunately, depends on your experience level.

The first is to use an inbound trunk rule that sends your calls through the SetCallerID module and monkeys around with the Caller ID of the inbound call.

The other is to look in /etc/asterisk/extensions for the “from-pstn-e164-us” context, copy if to extensions_custom.conf, rename it, and extend it to do what you want. Once there, you can point your incoming route through it and let it sort out the caller ID field.

Like I said - an easy way and a hard way.


I did something similar… but I was just adding 0’s or 00’s to the number… so wouldn’t be suitable for you…

However the following should do what you want (not tested; so test it).

Add/change the incoming context on the trunk to be:

then edit

nano /etc/asterisk/extensions_custom.conf


; Get the length of the current CLID Number
exten => _X.,1,Set(CLIDLen=${LEN(${CALLERID(num)})})

; If the CLID Number is less than 7 dont inpect further, assume short number
; from Telco..  not standard CLID, and move to end, otherwise inspect to see
; if we need to change the CLID.

exten => _X.,n,Gotoif($["${CLIDLen}" <= "7"}]?end:checkCLID)

; If first two numbers of CLID number are 00, go to changeint
exten => _X.,n(checkCLID),Gotoif($[ "${CALLERID(num):0:2}" = "00"]?changeint)

; If first two numbers of CLID number are 06, go to changeloc, else move to end
exten => _X.,n,Gotoif($[ "${CALLERID(num):0:2}" = "06"]?Goto(changeloc):Goto(end))

; Change the CLID to be '+[current CLID, less first two digits]
exten => _X.,n(changeint),Set(CALLERID(num)=+${CALLERID(num):2})
exten => _X.,n,Goto(end)

; Change the CLID to be '+3[current CLID, less first digits]
exten => _X.,n(changeloc),Set(CALLERID(num)=+3${CALLERID(num):1})
exten => _X.,n,Goto(end)

; End, goto from-trunk (which would normally be the context you would use)
exten => _X.,n(end),NoOp(CLID is ${CALLERID(num)})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)
include => from-pstn
; ------> end [clidchange]

I’m sure there are smarter ways, but I think that will sort your requirement.