Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Pages Menu
TwitterRssFacebook

Posted by on May 16, 2016 in Development, Skype for Business® (Lync®)

Skype for Business Click to Call Google Chrome Extension

Skype for Business Click to Call Google Chrome Extension

Aaaaages ago, I wrote a small plugin for Internet Explorer to allow you to select a phone number on a webpage and call it in (what was then) Lync.

Fast forward just over 4 years and I found myself selecting a phone number in Google Chrome and wondering why I couldn’t automatically call it in Skype for Business.

So I wrote a small Chrome plugin to automate this functionality. It’s very simple, for any text you select and right-click on, a new “Call in Skype for Business” menu option will be shown. This will take the selected text and parse it with the tel: protocol – this means that it will open with whatever application you have associated on your computer with the TEL protocol. (if this isn’t Skype for Business you can easily change it by going to Control Panel > Programs >Default Programs):

menuitem

The plugin is available now on the Chrome Web Store, totally free. The source is over at GitHub if you want to see how it’s done (or read on for more technical detail).

I just have one request: if you use it and like it, please rate it. There are thousands (millions?) of Chrome plugins, and so people will only find this one if it’s well rated. Thanks!

The Technical How

Invoking a local application using a protocol such as TEL from a website is actually quite tricky. It just falls into the slightly murky waters of websites controlling local applications, so it’s not something that browsers let you do easily.

When I wrote the Internet Explorer version I had to open a new page and then use window.move to navigate to the TEL:// URI. I wanted to avoid doing this if at all possible.

The approach I ended up taking in the end was to create a new anchor tag with a link to a TEL address, made up of the selected text. I then added this link to the page DOM (it had no text so you wouldn’t see it). Then, I invoke the click action on the DOM element – as if you’d clicked it. It turns out that Chrome is happy with this, and launches the External Protocol Request prompt before handing off the URI to the protocol handler on the local machine (such as Skype for Business).

After you take away the manifest file needed for the plugin and the code that registers the plugin with the context menu, the actual JavaScript that does the work is really quick small:

1
2
3
4
5
6
7
8
9
10
11
12
function onClickHandler(info, tab) {
 
chrome.tabs.executeScript ({
code: 'if (document.contains(document.getElementById("ThoughtStuffSfBpluginlink"))) { document.getElementById("ThoughtStuffSfBpluginlink").remove();}'});
 
chrome.tabs.executeScript({
code: 'var a = document.createElement("a");var linkText = document.createTextNode("");a.appendChild(linkText);a.title = "my title text";a.href ="tel:' + info.selectionText + '";a.id = "ThoughtStuffSfBpluginlink";document.body.appendChild(a); document.getElementById("ThoughtStuffSfBpluginlink").click();'});
 
chrome.tabs.executeScript ({
code: 'if (document.contains(document.getElementById("ThoughtStuffSfBpluginlink"))) { document.getElementById("ThoughtStuffSfBpluginlink").remove();}'});
 
};

The first and third script executions do the same thing: remove the anchor tag. In an ideal world I remove the tag immediately after using it, but the first execution is there just in case something happened previously – it’s important that I don’t create two DOM elements with the same ID otherwise the wrong one could be used in the second execution.

The middle script execution is the one that actually does the work – creating a new anchor tag, setting the href, adding it to the body, and finally invoking the click() action on it.  That’s it!

 

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

6 Comments

  1. This is a very useful extension. However, if the *gmail chat* is enabled then it does not work, but always tries to use hangout for making voice calls. Any idea on how to avoid that other than diabling chat?

    Another useful extension would be to create Lync meetings in the google calendar as easily as you can add Hangouts meetings….

  2. The Chrome extension doesn’t exist any more.

  3. The Google Chrome link to the Skype for Business Click to Call extension no longer works. Can you resubmit the extension or provide another link, please? Thanks!

  4. I can’t find this plugin in the store any more

  5. Hey this is exactly what I need and couldn’t find it anywhere! thanks for sharing, however, the Chrome links seem to be dead and I can’t find it on the chrome store. Are you planning to make an updated version

    Many thanks,
    A

  6. Hey this is exactly what I need and couldn’t find it anywhere! thanks for sharing, however, the Chrome links seem to be dead and I can’t find it on the chrome store. Are you planning to make an updated version

    Many thanks,
    A

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share to Microsoft Teams