Hi,
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:
context=clidchange
then edit
nano /etc/asterisk/extensions_custom.conf
[clidchange]
; 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.
Cheers