Bridge Communications

Saturday, September 16, 2017

Getting Started with Microsoft Teams Tabs - Part 2

Microsoft Teams is a chat-based collaboration tool that is part of the Office 365 suite of services. Teams enables local and co-workers to work together and collaborate through a common work-space, using features such as team chat, one-on-one chat and document collaboration.

Web Content

When it comes to Teams tabs, and what will soon be know as Teams apps, a secure website is how you will interact with the Teams client.  Today we will focus on the configuration page.  If you remember the manifest discussion from last week you will recall this section.

"configurableTabs": [ { "configurationUrl": "", "canUpdateConfiguration": true, "scopes": [ "team" ] } ],

So when we install our Teams app we have the option to specify a custom configuration page.  Why would we want to do this?  Let's say our app was going to map the current location of our Teams members.  We may want to give the users the option to user Google Maps, or Bing.  The configuration page will let them choose when the app is set up.


There are 2 requirement that have to be met for a configuration page.

1.  You must host it in a https secure location
2.  You will need to call microsoftTeams.initialize() in your js code

Here is a sample of our map selection configuration page.

<html> <body> <form> <input type="radio" name="maptype" value="bing" onclick="onClick()"> Bing Maps<br> <input type="radio" name="maptype" value="google" onclick="onClick()"> Google Maps </form> <script src=""></script> <script type="text/javascript"> microsoftTeams.initialize(); microsoftTeams.settings.registerOnSaveHandler(function(saveEvent){ var radios = document.getElementsByName("maptype"); if (radios[0].checked) { microsoftTeams.settings.setSettings({ entityId: "bing", contentUrl: "", suggestedDisplayName: "Bing Map", websiteUrl: "", removeUrl: "", }); } else { microsoftTeams.settings.setSettings({ entityId: "google", contentUrl: "", suggestedDisplayName: "Google Map", websiteUrl: "", removeUrl: "", }); } saveEvent.notifySuccess(); }); function onClick() { microsoftTeams.settings.setValidityState(true); } </script> </body> </html>

One important thing to note in the sample is the addition of this js file;

<script src=""></script>

This is essential for communication between your app, and the Teams app.  Don't forget to add it to the top of your <body> tag.

The other important thing to note is this line;


This piece of code lets Teams know that you have satisfied the configuration, things are valid, and the installation can proceed.  Without this you'll be stuck in a loop and not able to use your app.  Once you have save settings using  microsoftTeams.settings.setSettings  then you will use the getSettings to retrieve them in the application page.

Next week we'll start to look at what hooks our application page can have back to the Teams client.

Doug Routledge,  Teams, Skype for Business, SQL, Exchange, UC, 
Full Stack Developer  BridgeOC Bridge Operator Console
Twitter - @droutledge @ndbridge