Teams Clipboard Dialer
As you may know, I try to blog at least once a month. Although I’m a little behind this month, I’m still well on track to reach my goal in 2023 again.
I still got plenty of topics to blog about in my backlog but what I like most is when I discover something new and get so hyped out about it that I can’t just not blog about it right away.
Thanks to my awesome Discord community (join here) which is full of enthusiastic Teams Phone admins like myself, it was brought to my attention that Microsoft is making some changes to how normalization rules in Teams dial plans are applied.
TLDR;
I’ve created an app which allows you to call any phone number which has been copied to the clipboard simply by clicking an app on the taskbar or by pressing a hotkey. Skip to the bottom of this post if you’re only interested in the app.
What are Dial Plans and Normalization Rules?
Normalization rules are regular expressions which change certain phone numbers before they’re dialed in Teams. An easy example is e.g. that any Swiss phone number which is entered in the national format (with a leading 0
) is converted to E.164.
E.g. 044 123 45 67
is changed to +41441234567
before it’s dialed.
This rule is actually part of the system dial plans which are already included in Teams. Admins can create their own dial plans by creating so called Tenant Dial Plans.
You can view the built-in dial plans by entering the following in a Teams PowerShell session. Replace CH
with the country you want to check.
Get-CsDialPlan -Identity CH
Tenant Dial Plans
With tenant dial plans, it’s possible to create much more complex rules such as this one which contains a monster regular expression created by no other than Ken Lasko (UCDialPlans.com — Dial Plan Tools).
I don’t know why there are still people on this planet who think it’s a good idea to list a phone number in a format in which it simply does not exist. +41 (0) 44 123 45 67
or +41 0 44 123 45 67
are not valid phone numbers. That’s effectively the same as if I told people that my email address is mozzie(0)@heusser.pro
when in fact it’s mozzie@heusser.pro
. It’s either +41 44 123 45 67
(when calling internationally) or 044 123 45 67
(when calling from the same country).
From my experience many people also don’t know that you can dial an E.164 number even when calling from the same country. I wouldn’t be surprised if there is an exception to this rule in some countries, but it works in almost every case.
Unfortunately, the normalization rules which are built into Teams, don’t fix these numbers for us. If people dial a number with an illegal zero after the international prefix, the call will fail, since it’s an invalid number.
Since we can’t possibly knock some sense into every website owner that lists their phone number incorrectly or access and fix everybody’s precious personal Outlook contacts, adding Ken’s rule to a tenant dial plan was a great way of solving this particular issue.
But now Microsoft is taking this away from us.
This was the link that was shared on Discord:
M365 Changelog: (Updated) Changes in Normalization — Petri IT Knowledgebase
There is a Message Center post about this as well: MC536885. It mentions the following:
Stopping normalization on number that starts with plus sign (+)
Normalization in Microsoft Teams was not designed to do normalization when the phone number starts with plus sign (+) as documented, but we’ve never enforced this in the Teams desktop or Web client. We are planning to enforce this in the future but for now we recommend avoiding this pattern.
We are making this change to align with our Calling Service, other Teams services, Azure Communication Services SDKs, and other Microsoft services. Numbers that start with a plus sign (+) will not pass through any normalization rules.
Update 10.11.2023
The Message Center post was updated by Microsoft. They’re not following through with this anymore.
Updated November 2, 2023: Based on customer feedback we will not be moving forward with this change at this time. You can safely disregard this message. Thank you for your feedback.
/Update
Testing with PowerShell
I’ve noticed that something was not right, when the PowerShell commands to test dialed numbers against a tenant dial plan stopped matching numbers which start with a plus.
I have a tenant dial plan in Teams which contains Ken Lasko’s awesome normalization rule.
We can use the following PowerShell command to test a user’s normalization rules.
Get-CsEffectiveTenantDialPlan -Identity user@domain.com | Test-CsEffectiveTenantDialPlan -DialedNumber +410441234567 -TenantScopeOnly
As you can see in the screenshot below, the number starting with +
does not match any rules despite the fact the rule exists. The number starting with 00
is matched by another rule in the same dial plan.
Verifying Ken Lasko’s regular expression with regex101.com proves that it’s 100% correct.
What about the Teams Client?
Interesting enough, the Teams client still seems to match the rule from the tenant dial plan.
However, I suspect it’s only a matter of time before this stops working too.
Starting Calls from Outlook
If Teams is registered as the chat app for Microsoft 365 Apps (such as Outlook) we can call numbers which are stored on Outlook contacts.
The problem with this is that classic Outlook does not apply any normalization rules either. The number is called as it’s stored on the contact.
When I try to call this number, the call fails. You can see that the illegal zero was not dropped in the title bar of the call window.
It’s noteworthy that clicking a number in the old Outlook will start a call directly without prompting you to start the call in Teams.
In my tests with the new Outlook, the number was normalized correctly, even for a user who didn’t have a tenant dial plan assigned. This makes me believe that it’s actually the new Outlook which is applying the normalization rules. When you click a number in the new Outlook, you’ll get a prompt to start the call in Teams.
However, every time a number is clicked in the new Outlook, an annoying blank pop up is opened and it doesn’t even close once you have made the call.
Time to look for alternatives.
Alternative Solutions
Dialing phone numbers from other apps and links or even through a hotkey is not an uncommon ask from users.
If you’ve received this request before, you’ve probably stumbled upon this free app called Teams Wizard. This will allow you to start Teams PSTN calls by selecting a phone number and pressing the configured hotkey.
In Teams Wizard’s settings, there’s a setting called Enable normalization of phone numbers (Normalisierung der Telefonnummern aktivieren).
On first sight, it looks like this only goes as far as the Teams built in dial plans and won’t drop the illegal zero after the E.164 prefix.
However, when you click on Yes (Ja) the number appears correct in Teams, even if the user does not have a special tenant dial plan assigned.
So far so good. But the hotkey only works when you’ve selected a phone number with your mouse. Although it’s possible to just select a contact in old Outlook and then press the hotkey, the success rate is quite low. First of all, many contacts hold multiple numbers and it’s not possible to tell Teams Wizard which number should be called. Secondly, it’s not possible to select a number with your mouse in old Outlook. They can only be copied. But Teams Wizard does not monitor your clipboard. And copy/paste the number into another app (like Notepad) just to select it and then press the hotkey seems like one step too many.
While it’s possible to select phone numbers of contacts in the new Outlook, the experience isn’t great either. Because the new Outlook is also based on web technology, selecting a number with your mouse without triggering the calling link is a very tricky undertaking. And don’t forget all the ugly blank pop ups this will open.
If the new Outlook really does (and keeps on doing) number normalization, then I guess this problem will be mitigated at some point in the future. But a future where everybody only uses the new Outlook is likely still very far off. But I don’t even want to go into a discussion of new vs. classic Outlook and how some folks will cope (or not) with the new Outlook.
Therefore, I don’t think that it hurts to prepare ourselves for a world in which we can apply normalization rules outside of Teams and Outlook.
All of this got me thinking… wouldn’t it be awesome if we could have a way to instantly normalize and dial any number that has been copied to the clipboard…?
…Because copying a number with only one click is possible in both the new and the old Outlook.
Copying the number before calling it also provides great flexibility. Be it multiple numbers on a single contact or any phone number in any app or website. Heck, we could even use PowerToys’ text extractor feature (Win + Shift + T
) or the new Snipping Tool to extract and copy phone numbers from screenshots which got sent our way by people who were too lazy to put the number in a reusable format.
I Proudly Present: Teams Clipboard Dialer
I don’t know how to write and compile a proper app, but I like to think that I do know my way around PowerShell. And I think I’ve come up with a very neat solution here.
The Teams Clipboard Dialer consists of a PowerShell script and a Desktop shortcut which calls that script. The script reads phone numbers from the clipboard, normalizes the number, and then passes it to Teams to start the call.
All you have to do to start a call is to copy a phone number and either click the icon on the taskbar or press the configured hotkey.
If your clipboard is empty or doesn’t contain a phone number, a notification will be shown.
If your clipboard does contain a phone number, Teams will launch and ask you to start the call.
It’s even possible to call 1–4 digit long extension numbers or emergency numbers. Because these numbers don’t start with a +
the Teams tenant dial plan (if you have one configured) will still apply the normalization rules and convert the extensions to full E.164 numbers.
And no, there’s no browser pop up. Teams is opened directly. Luckily, I remembered that I blogged about creating Teams calling deep links a while ago, so I already knew how to create calling deep links. The part about how I can open Teams directly (without the detour in Edge) and have it start a call, I figured out by mere luck.
# Launch Teams to dial the number
Start-Process ms-teams "https://teams.microsoft.com/l/call/0/0?users=4:$phoneNumber"
I’ve only tested the Teams Clipboard Dialer on Windows 11 and Teams 2.1.
Setup
I also created an install script which copies the script to $env:APPDATA\OneDrive\TeamsClipboardDialer
and creates a shortcut in $env:OneDrive\Desktop
. Unfortunately, I didn’t find a way to automatically pin the app to the taskbar. When you run the script, you’ll see a pop up message which will pause the script and give you time to pin the app manually to the taskbar.
By default, the hotkey Ctrl + Shift + F8
is assigned to launch the app and dial numbers. You can change this by running the Createshortcut.ps1
script with the parameter -HotKey "Your hotkey combo"
.
You can find all the files in my GitHub repo. Also make sure to read the script headers carefully for more information on the available parameters.
If you’re interested in what normalization rules are applied, you can examine the script here. Basically, it removes any special characters like whitespaces, brackets, hyphens, dots etc. from copied phone numbers and then also applies Ken Lasko’s rule to get rid of those damn illegal zeros. You can read more about it in detail here.
By applying the normalization rules outside of Outlook and Teams, we get more control over it since we can do whatever we want. I guess if Microsoft won’t let us match numbers starting with +
any longer, we have to do it ourselves. Compared to the Teams Wizard, my solution gives us way more flexibility and visibility in terms of how numbers are normalized before they’re dialed.
Hold on… I Am Not Done Yet!
When I realized that I was on to something, I just couldn’t let it go. I replicated the whole functionality in an iOS shortcut. I don’t know why but every time an Android Fanboy asks me why I prefer the iPhone over Android I forget to mention Shortcuts. It’s literally the most underrated feature of iOS.
The shortcut uses the exact same regular expressions as the PowerShell script to normalize the numbers. (Yes, that’s possible in Shortcuts.) It also gets the phone number from the clipboard and will display the same hints if there’s no phone number stored in the clipboard.
Once the number has been normalized, the Shortcut will ask you to start or cancel the call. On iOS this step is handled by the Shortcut and not in the Teams app itself like it is the case on the Teams desktop client.
Get the Shortcut
You can download and import the Shortcut via iCould.
I’ve tested the shortcut on an iPad and an iPhone both running iOS/iPad OS 17.0.3. When you run it for the first time, you will need to confirm a couple of privacy prompts and allow it to run all the actions without asking again. After that, you’re good to go.
Showtime
This animated gif demonstrates how it works on iOS. The number has already been copied to the clipboard before the shortcut was executed.
Summary
When I first read the MC post about normalization rules no longer matching numbers starting with a+
I panicked a little. But now that I’ve done the research and came to the conclusion that having an app which normalizes and calls numbers from the clipboard, is actually a very nice and versatile solution and I’m very much relieved. And having the same functionality on iOS is an awesome bonus.
I hope you like what I’ve done and that you can make use of it as well. As always, all the code for the Teams Clipboard Dialer is provided free of charge. If you would still like to support my work, feel free to buy me a coffee over at GitHub Sponsors.