Lync Dial Plans and Normalization Rules


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.
If the pattern to match or the translation rule does not meet your exact requirements, manual editing is allowed.

The normalisation rules are checked in order from top down, the first match is the only translation performed.

Example Normalization Rules

NameStarting DigitsLengthDigits to removeDigits to addPattern to matchTranslation rule
4 Digit Extension3Exactly 40+35320911^(3\d{3})$+35320911$1
International Numbers00At least 22+^00(\d*)$+$1
National Numbers0At least 11+353^0(\d*)$+353$1
Emergency NumberNANANANA^(999$|112$)+$1
(Note: these rules are specific to Ireland, Comreg Numbering Plan specifies 020 91X XXXX for 'Drama' use, similar to 555 area code in US)


 

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.

NameDialed number to testExpected translation
Local extension3001+353209113001
International Number0018095556789+18095556789
National Number0209113002+353209113001
Emergency Number112+112
Emergency Number999+999

 


 

9 comments:

  1. Excellent info. I wanted to point out that the example for "?" is incorrect. The example shown does not include a question mark.

    ReplyDelete
  2. Mike

    You 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).

    ReplyDelete
  3. Hi Mike,

    Short 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

    ReplyDelete
  4. 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.

    ReplyDelete
  5. Any idea on the uk 101 number?
    I have my 999/112 numbers working fine but calls to 101 fail.

    Thanks
    Rob

    ReplyDelete
  6. Looking for help: we have numbers +1 (xxx) xxx – xxxx ext. 123
    How do I normalize this and get it to show up in lync, looking same way.

    ReplyDelete
  7. Thanks for this article, without something like this it's hard to get a handle on what is actually relevant in the MSDN articles.
    Question 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?

    ReplyDelete
  8. Hi,
    great 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

    ReplyDelete
  9. What about wrong formatted personal phonebook entrys?
    as 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

    ReplyDelete