Remove local prefix from caller id on incoming calls on a sip trunk

Hi,

I’m on FreePBX 13.0.195.4. How do I strip of first 2 digit (apparently is my own country code) 65 prefix from caller ID on incoming calls on a specific SIP trunk? I would like to have it detected on a 10 digit number starting with 65, to strip of “65” from the caller ID. Say 6512345678 to show on our extension 12345678 instead.

Thank you.

In your “extensions.conf”, there is a context called “something-e164-something” (I don’t have access to a server here at the church). Copy that to the extensions_custom.conf and change the name to “from-external-no-country” (or something) and change it to remove the digits you want to remove. There are lots of ways to manipulate both the incoming “from” DID (which is like the ‘12345678’ in your question) and the CID (which is going to be the caller ID in your phone).

If you are trying to strip off the Country Code on YOUR inbound DID, you can usually ask your provider to not send that. The inbound route will use whatever your provider sends as the DID for the route, so you’re kind of stuck there.

I’m still unable to find the context you are refering to. Any reference further than this?

Thank you.

Take a look at the section starting
[from-pstn-e164-us]
and use it as an example. I assume that you want to convert all numbers into the format you would use to dial them. Do you need to handle Malaysia / Indonesia specially?

For example:
65 6222 8888 -> 6222 8888 (Singapore)
60 3 2345 6789 -> 020 3 2345 6789 (KL)
66 2 222 3333 -> 001 66 2 222 3333 (Bangkok)

Otherwise, please explain the desired behavior.

can you help with re-adding back 65 on follow-me outbound call ? when 65 is already removed, mobile phones will not display it as a Singapore number anymore.

Just make an Outbound Route with
Prepend: 65
Match Pattern: XXXXXXXX
and the desired trunk(s). If another route would match 8 digits, put this one above it.

This will also allow your users to dial 8 digits when calling within Singapore.

Only Singapore number 65 6222 8888 -> 6222 8888 (Singapore)
I’m using a sip account, trying to strip off local country code when we receive incoming call.

I am trying to do the inbound else I will see numbers like 6565XXXXXX which is difficult for reporting and search, not so much on outbound issue.

If all you are trying to do is rewrite 10-digit incoming caller IDs beginning with 65 to 8 digits, then a custom context such as:

; Strip 65 prefix from SG caller ID
[strip65]
exten => _./_65XXXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => _.,n,Goto(from-pstn,${EXTEN},1)
exten => _.,1,Goto(from-pstn,${EXTEN},1)

should do that. Set the context for the trunk in question to strip65. (If the trunk is sending e.g. +6562228888 then you’ll have to modify this accordingly.)

But I don’t know whether that is consistent with other formats on your system. From an extension on your PBX, how do you dial a local SG number (just 8 digits, or something else)? How do you dial international numbers (just starting with the country code, or is some prefix needed)? Is Malaysia or Indonesia treated specially?

For local SG number, just dial 8 digit, while all other countries including Malaysia and Indonesia have to include country code.

Do I set the context you mention in extensions_custom.conf file?

I tried there, but still see incoming call with 65XXXXXXXX.

Did you set the context of your incoming trunk to strip65 (or whatever you called it)? Applied config changes?

Make a test incoming call and look at the Asterisk log. Do any entries show strip65? If so, do they show the expected caller ID (10 digits starting with 65)?

If you still have trouble, post the log of a problematic call (mask phone numbers, IP addresses and anything else you consider personal, but maintain the format so the log can be understood).

Interesting easy-to-use dialplan. In Singapore you can mostly get away with that, because nearly all international numbers are longer than 8 digits, when the country code is included. However, there are a few exceptions; for example, see https://en.wikipedia.org/wiki/Telephone_numbers_in_the_Solomon_Islands . http://www.visitsolomons.com.sb/accommodation/hotels/agnes-gateway-hotel is at +677 62133. You could accommodate such a case by allowing the extension user to dial e.g. 001 677 62133,

You mean outgoing? Not so much on outgoing as I can remove the country code or append. But more to incoming which is still showing 6512345678 which i want it to show as 12345678. Still unable to get this resolved. Maybe I don’t know which file to put in the context as you mention as I am using the GUI of freepbx and amend extensions_custom.conf file. Don’t know if this is right.

extensions_custom.conf is the correct file. If the log shows that your context is not being executed, perhaps you have multiple trunks with the same provider and Asterisk is associating the incoming call with a different one.

If the context is being executed but not rewriting the number, check the format of the incoming caller ID. For example, there may be a leading + (that you also should remove).

On most systems, you want incoming caller ID and outgoing formats to be the same (so you can return a call from History, save it to Contacts, etc.)

it’s better to have a prefix to call overseas number so that your user can call out toll-free Singapore numbers which is conflicting with USA numbers.

etc: 1800 1111111 (SG) and 1 (800) 280 4331 (USA)

Yes, that’s the reason why I want to remove the country code for incoming. Now I have to figure out how to let asterisk associate the incoming call with the right context. How do we associate one SIP trunk to one context?

Good idea, may need to think of how to differentiate… Any good idea on dial rules?

You specify the context in the trunk definition. The keyword is “context=” IIRC.

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