For Enterprise Voice, Lync requires a Dial Plan to be defined. The Dial Plan will have a number of normalization rules that convert the number typed in by the user (or selected by them from an Office application) and convert it to E.164 format. Normalization rules use .Net regular expressions. The objective is to match what the user has typed in and apply a translation to convert it to E.164. The dial plan is configured under Voice Routing in the Lync Control Panel. The dial plan can be scoped at the Site, Pool or User level.
Regex Basics
There are a small number of Regex elements used in Lync Normalization rules are these are described here.element | Meaning | Example | Explanation of example |
^ | Match at beginning of string | ^123 | Match the digits 123 at the beginning of the string |
() | Captures the matched subexpression | (456) | Capture what is between the parentheses into a numbered variable, starting at 1 which can be accessed as $n, eg $1 |
* | Specifies zero or more matches | \d(*) | |
+ | Specifies one or more matches | \d(+) | |
? | Specifies zero or one matches | \d(+) | |
{n} | Specifies exactly n matches | \d{4} | Match 4 digits |
{n,} | Specifies at least n matches | \d{3,} | Match at least 3 digits (with no limit to number of digits matched |
{n,m} | Specifies at least n, but no more than m, matches. | \d{3,6} | Match at least 3 digits but no more than 6 digits |
\d | Matches any decimal digit | ^\d | Match any decimal digit (at the beginning of a string) |
| | Matches any one of the terms separated by the | (vertical bar) character | 134 | 135 | Match either the string 134 or the string 135 |
$ | The match must occur at the end of the string | ^(123)$ | Match exactly digits 123 (and not 1234) |
Translation
Regex is used for translations following matches. In the case of Lync, this allows the addition of a leading + symbol and the insertion of digits, either from the matched string (S1) or fixed digits.Lync provides a normalization rule builder that guides you through the process of defining regular expressions that will cater for most circumstances. The generated regular expression can be hand modified to handle more complex situations.
The normalization rule builder has four steps, steps 1 and 2 match the pattern and steps 3 and 4 perform the translation.
- Starting digits: (Optional) Indicate the leading digits of dialed numbers you want the pattern to match. For example, type 234 if you want the pattern to match dialed numbers beginning with 234. This will result in a match pattern of ^(234)
- Length: Indicate the number of digits in the matching pattern and select whether you want the pattern to match this length exactly \d{4}, match dialed numbers that are at least this length (\d{3}\d+), or match dialed numbers of any length (\d*).
- Digits to remove: (Optional) Indicate the number of starting digits to be removed from dialed numbers you want the pattern to match. This will change how digits are captured into variables.
- Digits to add: (Optional) Indicate digits to be added to dialed numbers you want the pattern to match.
The normalisation rules are checked in order from top down, the first match is the only translation performed.
Example Normalization Rules
Name | Starting Digits | Length | Digits to remove | Digits to add | Pattern to match | Translation rule |
4 Digit Extension | 3 | Exactly 4 | 0 | +35320911 | ^(3\d{3})$ | +35320911$1 |
International Numbers | 00 | At least 2 | 2 | + | ^00(\d*)$ | +$1 |
National Numbers | 0 | At least 1 | 1 | +353 | ^0(\d*)$ | +353$1 |
Emergency Number | NA | NA | NA | NA | ^(999$|112$) | +$1 |
Dial Plan Testing
In the Lync Control Panel, we can test individual normalization rules or we can create a series of tests that can be saved and run to ensure our normalization and routing functions correctly.Name | Dialed number to test | Expected translation |
Local extension | 3001 | +353209113001 |
International Number | 0018095556789 | +18095556789 |
National Number | 0209113002 | +353209113001 |
Emergency Number | 112 | +112 |
Emergency Number | 999 | +999 |
Excellent info. I wanted to point out that the example for "?" is incorrect. The example shown does not include a question mark.
ReplyDeleteMike
ReplyDeleteYou certainly are trying to make life hard for yourself. I can't think of a way to do what you want. The normalization rules are essentially regex expressions but if there is no relationship between DID number and the corresponding extension then the regex won't work (or at least would have hundreds of 1-1 mappings).
Hi Mike,
ReplyDeleteShort answer is you can't. If (like me) you're stuck with DIDs that don't match you internal extensions in some fashion, you'll have to create a new normalization rule on your dial plan to match. i.e: (4 digit dialing)
User 1
Normalization Rule: ^(xxxx)$
Translation Rule: +1xxxxxxxxxx;ext=$1
Your only other option is to force everyone on your org to use their assigned when dialing internally or reassign all the extensions to match the DID. Probably not a great option as that will likely cause you even more headaches.
Best of luck.
Ivan Smith
I have the following scenario I am looking for help on. We have lync connected into our Cs1k PBX. For now everyone has a number configured into the pbx and has the same number configured in lync but with a leading 0. We can call from lync to the IP soft clients but cannot call from the soft client to the lync 5 digit number (no dial plan found) is the result of the log. Everything else is working fine from lync, external pstn calls out, calls from the pstn into the conference bridge work fine, lync to lync work fine. Looking for what type of dial plan I need to configure.
ReplyDeleteAny idea on the uk 101 number?
ReplyDeleteI have my 999/112 numbers working fine but calls to 101 fail.
Thanks
Rob
Looking for help: we have numbers +1 (xxx) xxx – xxxx ext. 123
ReplyDeleteHow do I normalize this and get it to show up in lync, looking same way.
Thanks for this article, without something like this it's hard to get a handle on what is actually relevant in the MSDN articles.
ReplyDeleteQuestion though:
If \d{4,} is the same as \d{3}\d+ - why does Lync default to the latter with the rule builder when the former is more space efficient? Is there a drawback to using this?
Hi,
ReplyDeletegreat explaining!
What about special characters like () ?
Wrong formatted personal contacts are often stored following:
+49(0)301234
should be normalized to
+49301234
Is () a to-do for normalization, that i need only to delete the "0"
thanks
What about wrong formatted personal phonebook entrys?
ReplyDeleteas example staff save often phonenumbers in this format:
+49(0)30123456789 (dialing failed because of "0")
better would be:
+49 (30)123456789 (dialing whit succeed)
correct would be:
+4930123456789 (dialing with success, but difficult to read contact's phone number
thanks