Inbound E.164 Caller ID - How to change the display format?

We are based in the UK and our telephone carrier has recently informed us that they are about to start sending the Caller ID of inbound calls over our SIP Trunks in the standard E.164 format - e.g. +441782987654

At the moment everything works perfect for us in that the above same number is sent as 01782987654 and this is visually displayed clearly on our telephones and also used to lookup the number in the Asterisk Phonebook.

I would be so grateful if somebody could advise me on how to configure our system to replace the +44 element of inbound Caller ID numbers sent in the E.164 format with a 0?

i.e… Replace a inbound Caller ID number sent as +441782987654 with 01782987654

Any help would be greatly appreciated :slightly_smiling:

Asterisk comes with (in /etc/asterisk/extensions.conf)

[from-pstn-e164-us]
exten => +1NXXNXXXXXX/+1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => _+1NXXNXXXXXX/_NXXNXXXXXX,2,Goto(from-pstn,${EXTEN:2},1)
exten => +1NXXNXXXXXX/+NX.,1,Set(CALLERID(number)=011${CALLERID(number):1})
exten => _+1NXXNXXXXXX/_011NX.,n,Goto(from-pstn,${EXTEN:2},1)
exten => _+1NXXNXXXXXX,1,Goto(from-pstn,${EXTEN:2},1)
exten => [0-9+]./+1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => _[0-9+]./_1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):1})
exten => _[0-9+]./_NXXNXXXXXX,n,Goto(from-pstn,${EXTEN},1)
exten => [0-9+]./+NX.,1,Set(CALLERID(number)=011${CALLERID(number):1})
exten => _[0-9+]./_011NX.,n,Goto(from-pstn,${EXTEN},1)
exten => [0-9+].,1,Goto(from-pstn,${EXTEN},1)
exten => s/
+1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => s/NXXNXXXXXX,n,Goto(from-pstn,${EXTEN},1)
exten => s/
+NX.,1,Set(CALLERID(number)=011${CALLERID(number):1})
exten => s/_011NX.,n,Goto(from-pstn,${EXTEN},1)
exten => s,1,Goto(from-pstn,${EXTEN},1)
;-------------------------------------------------------------------------------

You will need to write your own

[from-pstn-e164-uk]

in /etc/asterisk/extensions_custom.conf and send you calls there. US is +1 UK +44 the + is a metasymbol for 011 (US) or 001 (UK) , take it from there and let the other limeys know how you DID it. (sorry the DID was a lame joke)

I’m pretty sure that 99.9% of UK numbers are closed dialing there might be couple open patterns left though.

so if you live in or call Brampton, you will need an exemption.

Presumably you will need your outbound calling to reciprocally reverse the local dialplan your users are used to using to normalize to e164.