Hi, with standard configuration freePBX sends a CID with +[Countrycode][Number] to the phone. If you want to call back, a number 0[Number] or 00[Number] is required.
Sadly there seems to be no predefined solution.
Some suggest, this can be solved with outbound rules. Although this would be the most logical step, it didn´t work for me.
Others modify extensions_custom.cfg. I don´t know if this is a good idea. Is it resistant against updates and restore? The file seems to be empty on default?
What do you think is best practice for this issue?
Find a provider that is consistent between caller ID and destination number formats. It isn’t Asterisk that is adding the +, it is the provider, and if the provider uses this on caller ID, it should accept it on dialled numbers.
Hi, @david55 this would be a workaround, but not best practice. There should be a solutions to use most (or even any) of the providers with freePBX.
Personally, I use this solution:
extensions_custom.conf
[from-pstn-remove-plus]
exten => _X!,1,GotoIf($[“${CALLERID(num):0:3}” != “+55”]?noplusatstart)
exten => _X!,n,Set(CALLERID(num)=${CALLERID(num):3})
exten => _X!,n(noplusatstart),Goto(from-trunk,${EXTEN},1)
After you create this custom-context, you just need to define it in the trunk configuration
This is a dialplan that removes the “+” and the countrycode from the number (basically removing the first three digits that are always fixed, in my case “+55”), so I receive the callerid in an appropriate format to call back (my outbound rules already add the necessary 0 in front of the number)
Hi, @ErikVandergeld by the way for most cases 3 digits fixed is correct. Country codes however can be 1 or 3 digits too.
Is it correct, with custom-context you referre to the field , default setting is “from-pstn”. The value in this field is used as the header for the script in “extensions_custom.conf”? Has the field entry to be unique or can it be used for all trunks? Has it to be changed at all, if all trunks have to be processed by the script?
Contexts can be shared between endpoints.
You can define this context in the trunks you want to use it, which (sometimes) may depend on the format in which the callerid is sent
For example: I have two trunks on my PBX, one from a large telecom company and the other from a VOIP provider, the telecom company’s trunk sends me the callerid as “+55XXXXXXXXXXX” so I use that context in its configuration:
[from-pstn-remove-plus]
exten => _X!,1,GotoIf($[“${CALLERID(num):0:3}” != “+55”]?noplusatstart)
exten => _X!,n,Set(CALLERID(num)=${CALLERID(num):3})
exten => _X!,n(noplusatstart),Goto(from-trunk,${EXTEN},1)
Now the VOIP provider sends me this without the “+”, so the context is slightly modified:
[from-pstn-remove-country]
exten => _X!,1,GotoIf($[“${CALLERID(num):0:2}” != “55”]?noplusatstart)
exten => _X!,n,Set(CALLERID(num)=${CALLERID(num):2})
exten => _X!,n(noplusatstart),Goto(from-trunk,${EXTEN},1)
See that in the first line, the country code (two digits) is defined and in the next lines we remove the first two digits of the number
So if you want all your trunks to pass this rule, you could set the context for all of them to be “from-pstn-remove-plus” (or whatever name you use in extensions_custom.conf)
Asterisk is distributed with a context in /etc/asterisk/extensions.conf called
;
;
[from-pstn-e164-us]
.
.
.
I suggest that whatever your country-code is, it might help you study it for how the various possible formats are handled to ‘normalize’ dialing to your own [from-pstn-e164-br]
where br is your country-code.
It should be noted that the -us context normalizes to 10 digit dialing, yet more and more locales are needing or at least accepting, 11 digits , so I suggest you bear in mind what is the recognised diling for the users in your locale is , so callers can be called back easily. Outboun\d routes can be handled both generically in the route and more specifically individually in the trunks.
First in [admin][config edit] there is “custom_extensions.conf” and “extensions.conf”. The second one should not be edited because it is modified by gui. Is this correct?
Second I have tried Erik´s script in “custom_extension.conf”. I modified it to
[from-pstn-remove-plus]
exten => _X!,1,GotoIf($[“${CALLERID(num):0:3}” != “+49”]?noplusatstart)
exten => _X!,n,Set(CALLERID(num)=0${CALLERID(num):3})
exten => _X!,n(noplusatstart),Goto(from-trunk,${EXTEN},1)
(+49 for Germany and adding a 0 in front of the number)
Nothing happens. This is o.k… After changing the context in the trunk configuration, the number can not be reached anymore. Like there is no “inbound rule”. The log shows:
to extension ‘+49…’ rejected because extension not found in context ‘from-pstn-remove-plus’.
I have modified the inbound rule from ‘+49…’ to ‘0…’. Same result.
What have I forgotten?
Normalizing sounds good. But first I would be glad, if basic functions for the home country will operate with the favorite trunk…
X does not match + just 0-9.
Hi dicko, can´t exactly comprehend, what you mean with “X” and how to solve it. Could you or somebody give me a hint, where to find a detailed description of the language or what´s the name of the language to search for a description. Thanks.
Here ‘X’ is asterisk dial-plan talk for ‘[0-9]’, ‘Z’ is ‘[1-9]’ and ‘N’ is ‘[2-9]’ finally ‘.’ is for any-single-character including ‘+’
For dial-plans by country I use wikipedia, for an example
Idealy you will cover local , long distance, Euro and International dialing by any idiom found in your locale. also cover emergency and other common ‘short number’ of relevance and everyone will be happier.
Globally, Phone numbers fit within E164 :-
In some countries all phone numbers are the same length (fixed) unfortunately for you, Germany is not one of those so a complete set of unique (there was a truly good historical reason for that but it didn’t work out) MostSignificantNumbers is much longer than the 1NXX (then NXX-XXXX) of NANP, but that’s another story.
E164 also covers mobile/cell phones whereby any James Bond ‘InternationalWhatAGuy’ knows a long press of the 0 will turn into a + which is the intermationally accepted meta character for international call prefix, 011 in NANP 00 in most of the rest of the world, The + is that he can dial M (for murder or mothering) from London, Moscow or Jamaica
coming back to the original question: Why is it required for a call-back to dial a number starting with 0 or 00?
The only thinkable reason is a missing route which includes a respective dial-plan. First of all, the dial-plan is stored in chapter “dial patterns” of the outbound route.
My dial patterns here allow European country codes, and German mobile pre-codes. Same situation, where no numbers starting with +xx are possible, because not defined.
adding a line like the following one would change +49 into 0. Which can also elaborated to some more country-codes:
PS: Do never forget to create a own route for emergency-numbers, or allow these numbers in the used dial pattern! You must allow 110, 112 at least and/or further ones. They never shall get a country-code nor a area-code/city-code. The outgoing number must represent the address of your real location, otherwise emergency staff will be send to a wrong location.
I would comment that 003[0-59]. is incorrect, did you mean [0-5,9] ? if you did, then I guess you don’t like Hungary +36 nor any of the countries that inherited East German +37. after it’s demise nor those from the breakup of Yugoslavia +38.
Also 01[5-7].is redundant as it is a subset of 0N.
yes. 0151 to 017x is doubled. I’m going to delete the 0N-line. Thanks so far.
Concerning eastern Europe countries, also yes, comma is missing. You see, my dial patterns are some years old, but included Bulgaria at that time.
Concerning the +xx issue it would it work with:
- line: prepend 00 delete + for dialed numbers such as +3[0-9]Z.
- line: prepend 00 delete + for dialed numbers such as +4Z.
- line: I have no idea about non-german mobile numbers, but for german ones:
prepend 0 delete +49 for dialed numbers such as +491[5-7].
However, even my corrected 00-lines should be allowed in addition in the dial-patterns, since it is not really sure that all phone providers are coming in with +49x. Specifically it is the case for mobile phone providers. - line: prepend 0 delete +49 for german numbers such as +49Z.
You should write or borrow a context
[from-pstn-e164-de]
using the same logic as [from-pstn-e164-us] in extensions.conf whereby all possible formats are ‘normalized’ to the comman dial habits of your locale, do the same for your outbound routes manipulating variouslyt if necessary for individual carriers, it is worth the effort and nobody needs to ask you what to dial, emergency then other ‘short numbers’ outbound should have highest priority
Thanks for the answers. I now tried to add a dial pattern to a working outbound route.
This was my first (failed) attempt to solve the problem. Now the pattern looks like this:
But if a I try to call back from the phone it doesn´t work. Asterisk log shows:
“Call (UDP:192.168.X.Y:5374) to extension ‘+49…’ rejected because extension not found in context ‘from-internal’.”
It seems to me like something has to be modified for “+” to work with dial patterns
Logs are always requested if not posted, use pastebin
You want:
prepend: 0
prefix: +49
match pattern: Z.
The match is done on the concatenation of ‘prefix’ and ‘match pattern’. If it matches, prefix is removed and prepend is prepended and the result sent on the associated trunk(s).
It looks like you don’t have an outgoing route to Deutsche Telekom or whom ever. The route used (…from-internal…) seems to look for internal extensions only and tries not to call an outside number. The outbound route should be relate to a registered trunk.
For incomming calls this trunk may have “from-pstn” or what dico recommends “from-e164-de” context.