Hi all. I have a number. For example, +49 8104 555555555. How can I make dialing +49 8104 555555555, 00 8104 555555555, 8104 555555555, 555555555 always the same action? Can this be done in one line, one exten?
I tried exten => _.5555555555,GoTo(incoming-office ,s,114). This does not work. This line accepts calls from both 555555555 and 555555551 and so on. I need a comparison on the last digits, in general.
Provided you know how many “last digits” you want to compare (which, for
example in Germany, is essentially impossible, because there is no standard
for the length of a telephone number), you can use the $LEN() function to find
out how many digits (or symbols, if you’re including “+”) have been dialled,
and then use ${NUMBER:chop} to remove the first “chop” digits off the front,
which you would calculate as (length-digits_to_keep).
Personally Iwould go about this the other way and ask “what prefixes are people
allowed to dial before a number my dialplan is interested in?” and then set up
an extension for each prefix, all pointing to a generic extension which then
does the dialling work for you.
For example (this is in AEL format, but that’s easy to adapt:
So, if someone dials a number starting with zero and followed by a non-zero
digit, that will strip the zero, prefix with the country code 0049 and then
pass over to the generic extension.
If someone dials anything starting with two zeros, that’s just processed as-
is.
If somedial dials a number starting with +, that symbol gets replaced with 00.
If someone dials a number starting with non-zero, it gets prefixed with 0049221
(which means Cologne, Germany) and then handled by the generic extension.
You can use negative values when substringing variables, to access from the tail of the number, however, the preferred approach in a case like this is to canonicalise the numbers, for example into E.164 format.
Dialplan . and ! wildcards can only be used at the end of a number.
Hi Antony! This number is not dialed by employees. Customers of one of the companies call this number (one of many). I want that when dialing (outside) this number, there will be a transition to a specific employee. It is defined in a different context and has nothing to do with the question.
The problem is that if you call from the CIS, then the number will be +49, if you call from Germany, then 555 55 555, if you call from Europe, then 00 8104 555 55 555.
Therefore, it is beneficial to make a comparison any digits 555 55 555 go to if. The problem is that we do not have the exact number of digits in front that need to be cut off. So, my question:
exten => (anymanydigits)5555555555,GoTo(incoming-office ,s,114) it is possible?
Do you propose to make, conditionally, three exten lines for a different possible set of a specific number? This is the solution, but I expected to be able to do it more elegantly)
I expect you to rewrite all the numbers into the +49 format, based only on length and initial digits, then use your individual extension matches on the result.
_+49., 1,GoTo(canoncalised,${EXTEN},1)
_00XXXXXXXXXXXXX.,s,GoTo(canonicalised,+49${EXTEN:2},1)
_8104XXXXXXXX.,s,GoTo(canoncialised,+498014${EXTEN:4},1) ; Might need to use exact length matches
_.,s,Hangup() ; should really use the correct cause code for an invalid number
etc.
Although, normally only one format would be assoiciated with any one source, and you would just have the appropriate GoTo in the initial context for that source.
As I understand it, in your example, all calls in the context are cast to the same beginning +49? Then we always get numbers of the same length and format. Is that the point? _00X wiil be +49X, etc?
Good point of view. But how to put it into practice with Germany? In Germany, there is no set length for a phone number. It can be 5-7-8 or even 9 characters, depending on the phone company. As Antony said in his post.