2018-02-04

This article will go over how to set up an MS Bot and integrate it within Microsoft Teams. It will go over the complete start to finish process and show a working bot in MS Teams that answers O365 FAQs.

Note: As this is Microsoft some of the navigation options may change over time and the screen clippings are seen may be different!

First thing first, what a Bot is – well a bot put simply is an application that can perform an automated task. The tasks vary from setting an alarm to ordering pizza. You have probably used a bot without even realising it – Siri and Cortana anybody?

This article will go through how you can create a bot using Microsoft Azure and surface this bot in Microsoft Teams. No development experience is needed to follow this article.

The Prerequisites

  • Visual Studio (optional)
  • Azure Subscription
  • Access to an MS Account
  • MS teams app installed

This article was done on a windows machine – I haven’t tested it on a mac, so if somebody does let me know (It should work).

Create the Azure Bot

This section will talk about how you create the Bot from the Azure portal

1. Log into the Azure Portal – https://portal.azure.com

2. Select New > Bot Service (preview)

3. Create the Bot and add the required information

4. Once you have selected ‘Create’ the Azure portal dashboard will load – once the BOT has finished provisioning an alert will appear. Navigate to the Bot via the alert and selecting ‘Go to resource’.

5. Create Microsoft App ID and Password

You are now required to create an app id and password. This is done so the BOT can authenticate with the BOT framework. Select the ‘Create Microsoft App ID and password’ – this will open a new tab

When creating the ID make sure you take a copy of it when the dialogue box opens!

Copy the app id and password to the Azure portal browser window as seen below

6. Choose a language

The Bot now needs a language. This enables the bot to be further developed. At current the two Options are C# or NodeJS. In this demo, I will select C#.

The next option is a template to choose. Please select the Question and Answer template.

Agree to the T&Cs and select ‘Create Bot’.

After you select ‘Create bot’ a dialogue box appears. Select ‘Create a New Knowledge Base’ in the drop-down

You may get asked to log in at this point – try and use the same account as the Azure subscription as I find this makes it easier to manage.

The bot will now provision – this may take a few minutes – time for a coffee?

Continuous deployment from source control (Optional)

This section will talk about how continuous deployment can be incorporated into the Bot. Please note this section is optional.

Once the bot has been created you can navigate to the Bot Service in Azure. In the BUILD configuration tab, a section for continuous deployment is visible. In this demo, I will select the source control provider as Visual Team Services.

A Visual Studio Profile is required. Add the URL to your visual team services site and generate an access token. Once the URL and token are added selected enable.

When the dialogue appears warning around enabling continuous deployment select Got It.

This solution can now be added to visual studio to make enhancements to the functionality of the Bot. Examples of this functionality may be authentication to resources to produce the QnA framework. This article won’t delve into how to add the repo to visual studio. Follow this article on how to configure the project to be maintained using visual studio.

Adding the Bot to teams

This section will describe how to add the Bot that has been created into teams.

1. Navigate to the bot in the Azure portal and navigate to the Channels tab.

This shows all the supported channels that the Bot can be added to. In this demo, the Bot will be added to MS Teams. Select the team’s icon. Once selected select the Done. The Microsoft Teams now appears under connect to channels section.

2. Now click the Microsoft Teams Text.

This will open a new tab asking you to open the bot in Microsoft Teams

Depending on the browser being used the dialogue may be different. If using Chrome select ‘Open Microsoft Teams’. The bot will then open in MS Teams.

 

The bot only currently responds to a singular input. Type in ‘Hi’ and see what you get back! See you have now just created a Bot – okay it doesn’t do much or answer many questions but it is a bot!..Now try and type something else and see what the response is. Yup, you guessed it ‘no match found’.

The next section will detail how to train the bot!

Qnamaker.ai – Making the bot more intelligent!

This section will show how to train the bot to be more intelligent and add different responses and questions.

1. Navigate to https://qnamaker.ai/Home/MyServices – if you get asked to authenticate login with the same account as you used earlier.

This will open the Microsoft QnA Maker. This is where the Bots ‘intelligence lives’ and can be improved upon.

When loading this page you should see the Bot that you have created is visible. It will be called something generic like ‘Basic QnA KB-YYY-MM-DD etc…’ Select the one that you have created – if you have more than one use the date times to work out which one it is!

2. Once the service is found select the pen icon to edit the bot.

This will open the Bot service up.

The Bot service has three headings on the left-hand side:

  • Knowledge Base – the questions and answers the bot service can actually answer
  • Test – section that you can test the knowledge base and configure responses
  • Settings – You can point the bot towards URLs to generate a knowledge base, select files that contain a knowledge base and rename the bot service.

3. The first thing we will do is rename the bot to something more ‘Friendly’. So Navigate to the settings and at the top enter a new service name.

Note: once you make a change to the service you need to select save and retrain and publish the service otherwise it won’t be visible – the publish button is always on the top right.

4. Next step is to add some more QnAs to the service. To do this select the navigation option Knowledge Base

  • Select Add new QnA Pair
  • Add the following:
    • Question: what is Office 365
    • Answer: O365 is Microsoft’s cloud offering of a selection of their products and services.
  • Select save and retrain
  • Publish the service

To test this navigate to teams and type ‘what is office 365’ – you are now prompted with the response ‘O365 is Microsoft’s cloud offering of a selection of their products’.

You can now add further QnA pairs – However, doing all of these manually could be pretty time-consuming. Fortunately, Microsoft allows you to point the Bot service at a web page.

5. Navigate to the settings option when editing the bot service.

This URL looks at the Microsoft FAQ page. Once added save and retrain the model then publish. After the publish has occurred edit the service and navigate back to the Knowledge Base and you will see a set of new QnA pairs

Now navigate to teams and ask one of the questions that you see in the list and see what happens.

You will also be able to type ‘similar’ questions to those that are found in the list and the answer should still be correct. Example type: ‘difference between o365 and office’ will return the answer assigned with ‘What is Office 365? How is it different from Microsoft Office?’

The last part of this application will be looking at how to train the model – this can be done in the test section. The idea of this is that when asking a question sometimes the incorrect answer is presented. This is where you can select the most appropriate answer.

In the text section type – ‘How is o365 different?’…This returns a result of ‘O365 is Microsoft’s cloud offering of a selection of their products and services.’ However, the most appropriate result would be the answer to ‘What is Office 365? How is it different from Microsoft Office?’ This can be done by selecting the alternate answer on the left-hand side.

Here, you can also look at adding alternate questions that could result in the answer. Doing this will amend the number of QnA pairs by adding the additional one to the answer you provide. Once complete save and retrain and publish the service.

Summary

So hopefully this article provides enough information in a clear and concise way to create a Bot and surfacing the Bot in Microsoft Teams. The application for these bots are endless, from diet responding bots, medical diagnosis bots to help desk bots. The one key point from using the QnA bots service is the more time you spend in the test and knowledge base sections the more reliable the answer would be. For more information on the QnA Maker visit:

https://qnamaker.ai/Documentation

A good extension to the above would be:

https://qnamaker.ai/Documentation/ActiveLearning

About the author 

Jack Binnall