Tuesday, January 8, 2013

Normalization rules order

I was troubleshooting a customer's normalization rules for international dialing, when I came the following conclusion: The order of the normalization rules in the DialPlan is important when you have more than one possible match.

In my setup, I was trying to accommodate how users might possibly try to dial an international number in different ways. Some users might have figured out how to use the + in their contact cards, or when dialing, and those are of no concern. But others will still tend to use "old-style" with a prefix, or forget the "+" all together.

For this I "always" create two simple rules:
One matching any number string longer than 8 digits (No extension in Norway is longer than 8 digits), and adding a + to it. This will Normalize any international number not beginning with a "+" and adding the "+" before routing.
New-CsVoiceNormalizationRule -Identity "Global/NO_INT_Digits" -Pattern '^(\d{8}\d+)$' -Translation '+$1'
The second rule was made to accommodate those who were dialing with the international prefix in front of the number (00)
New-CsVoiceNormalizationRule -Identity "Global/NO_INT_Digits00" -Pattern '^00(\d{8}\d+)$' -Translation '+$1'

What I have not considered before, is the order of which these commands are written. If you enter them in the order I have shown you here, the first rule will always take effect, and the stripping of 00 in the second rule, will never work.

So from now on, I will always add the most specific rule first, then the general rule.

Here's the "complete" list I usually use here in Norway:

New-CsVoiceNormalizationRule -Identity "Global/NO_3_Digits" -Pattern '^(1\d{2})$' -Translation '+47$1'
New-CsVoiceNormalizationRule -Identity "Global/NO_4_Digits" -Pattern '^(18\d{2})$' -Translation '+47$1'
New-CsVoiceNormalizationRule -Identity "Global/NO_5_Digits" -Pattern '^(0\d{4})$' -Translation '+47$1'
New-CsVoiceNormalizationRule -Identity "Global/NO_8_Digits" -Pattern '^(\d{8})$' -Translation '+47$1'
New-CsVoiceNormalizationRule -Identity "Global/NO_INT_Digits00" -Pattern '^00(\d{8}\d+)$' -Translation '+$1'
New-CsVoiceNormalizationRule -Identity "$Global/NO_INT_Digits" -Pattern '^(\d{8}\d+)$' -Translation '+$1'

Hope this saves you from some troubleshooting: Plan your Normalization rules carefully :)