E.164 Caller ID presentation

How do we standardize e.164 caller ID presentation on our system?
We are in Canada so phone numbers are 10 digits, e.g. 5141234567 and that’s the CID used for outbound calls instead of e.164 +15141234567 presentation. That’s not a problem for calls in North America but when we call long distance the overseas caller seas 5141234567 as CID which is PERU not Montreal Canada. Is there any way to fix outbound caller IDs to be sent in e.164 format at all times?

Yes, do this in the Outbound Routes.

Set the 10-digit caller ID for domestic routes and the E.164-formatted ID for international routes.

Thanks but I don’t see any option to do this in outbound routes. The only field to change callerID is “route CID” and this would not override the extension CID or change the outbound CID to E.164 format. I guess I am missing something.

I see. If you need to set the caller ID per extension then I guess your only choice is to set the E.164 format caller ID on each extension. Does your domestic provider reject it?

Yup. Not an option. In North America the 10-digit number format is preferable.
Only overseas calls must be be in E.164 format.

This was never a problem in the past. It has only come up recently because carriers started to provide CID on overseas calls. So now 5141234567 is Peru instead of Montreal Canada.

You might try setting up a pair of outbound trunks, one with the local extension Caller IDs enabled, and one with the International Caller ID overriding the extension CID.

You could also set up an outbound context that takes your Caller ID information and “transmutes” it into E.164 format on demand before you pass to the actual outbound trunk. Add the new context to your “extensions-custom.conf” and make sure you include it in your outbound context.

Thanks for the suggestion. Unfortunately outbound trunks don’t change individual extension CIDs. I can either “Allow Any CID”, “Block Foreign CIDs”, “Remove Cnam” or “Force a Trunk CID”. None of those options will solve my issue.

The outbound context should work but may be complicated to set up. Every call would have to be evaluated to decide if CID should be E.164 or not.

It turns out this does not work. Even if you set it in dialplan before routing to the trunks, the caller ID gets reset by the macro-user-callerid macro, which reads the caller ID value from the astdb.

@dcitelecom will have to customize that macro to add +1 in front of the 10-digit CID at the appropriate times.

Try adding to :-


something like:-

exten => s,1,Set(CALLERID(num)=${IF($[ ${LEN(${OUTNUM})}  =  10  ]${CALLERID(num)}:+1${CALLERID(num)})})
exten => s,n,MacroExit()

You forgot the ? sign
but that definitely works. THANKS.

Unfortunately there result is the same as changing the “Outbound CID” in the extension itself to E.164 so the CID number is changed for all outbound calls and not only overseas calls which is a bit overkill. It also creates a problem for me with a2billing as now all CIDs passed to a2billing are E.164 and no longer recognized.

Ideally I would want to change the outbound CID AFTER the call was passed to a2billing i.e. only for overseas calls. I wonder if there is a variable that is used by a2billing for outbound calls that is different from the CID variable used to authenticate the caller…

e.164 typically includes the meta-character + to be replaced with the locales international prefix , in your case 011, it does not REQUIRE it and a number of the format 1NXXNXXXXXX should always refer to a phone number in NANP, so you can probably omit the + from the if condition, it all works on the MSD dialled and with a 1 it is unique with 10 digit dialing not so much, but if you have a problem with that then surely you should take this problem to a2billing, FreePBX should surely not be expected to fix their lack of full e.164 support.

You misunderstood. I don’t need to send E.164 numbers to complete the call.
I simply want to send that format because the receiving party sees Peru instead of Montreal when the CID is 5141234567.

Using your predial-hook or changing the outbound CID in the extension directly, solves that issue (+ is optional) but now I have to change all stored callerIDs because in abilling I have it stored as 5141234567 and Asterisk is now passing it to a2billing as 1514… or +1514… and to change all those numbers would be my last resort.

Of course there would be no problem if I could change the outbound CID to E.164 format directly in a2billing after the users CID is validated, and I have posted on their site as well but don’t expect much help there as the forum is pretty much dead there.

I appreciate your help and understand you don’t want to support a2billing but I am simply trying to get as much input as possible.