Select Page

Microsoft Teams is part of the Office 365 collaboration portfolio and combines many of the Office 365 services in a chat based workspace. Microsoft Teams also has many extensibility points and this series will explore them. We’ll use a fictional example and build it up in stages throughout the articles. At the end of the series you’ll be left with a prototype you can explore and build upon.

Series index:

Building our bot

Before we begin we need to get the Visual Studio environment setup with a new project template. I’m using VS2015 so this is a little more manual than in VS2017.

https://docs.microsoft.com/en-us/bot-framework/resources-tools-downloads will have the latest information.

Once you create the project you add the Nuget package for ‘Microsoft.Bot.Builder’ to the solution.

The final step is to install the Bot Framework Emulator so we can debug our bot.

On F5 the browser will spin up and now we can check the basic Bot works off the template before we move onto coding.

BotInitial

Register your bot

Now go to the Bot Framework service to register the bot. We can fill out most fields except the Azure web url as we haven’t set that up yet at this point.

BotRegistration

Microsoft Teams .Net SDK

In order to use the feature of Microsoft Teams we will added the .Net SDk (NodeJS is available) so we can make use of it later.

BotTeamsNuget

Azure website

We’ll use Azure to host our bot. Rather than describe each step you can refer to the deploy your bot documentation. One additional step I would recommend is to create the app settings keys in the Azure settings to avoid sharing them via source control.

I also hooked up Continuous Deployment from Github just to save time.

Update your bot registration

Once we have our Azure details we can go back and update the bot registration with them.Once you have the bot running in Azure you can use the Bot Emulator with Ngrok to test it.

BotDeployTest

Adding the Microsoft Teams channel

In order for our bot to work in Microsoft Teams we need to enable that as a channel.

BotAddTeamsChannel

Adding QnA to your bot

In order to invoke our QnAMaker knowledge base we need to implement a custom dialog which handshakes our bot messages and the QnA Maker API. I’ve simply wrapped the basic logic and changed the bot api controller logic to invoke it instead of the default.

The QnA Maker has a subscription key and knowledge base key which I choose to store in the Azure app settings rather than hard code within the code.

BotAddingQnA

Create the Team package

In order to add your bot to Microsoft Teams we have to create a manifest.json and zip it up ready for sideloading. I added a short gulp task to do the zipfile creation. We’ll make this more feature rich in a little while.

BotPackage

Side loading the app

Side loading is the process of adding the app into your Microsoft Teams service. It allows you to grab the zipfile we just created and add it to a specific Team and then call the bot.

BotSideLoading

Next step

We’ve just built our knowledge base and bot and have seen it running in Microsoft Teams for the first time. The next step we’re going to add some Microsoft Teams a specific extension called ComposeExtension.