UCPrimer
  • Tech Blog
  • About UCPrimer.com

Build a Bot for MSTeams with Azure Bot Service and QnA Maker

3/26/2019

6 Comments

 
Picture
As mentioned in an earlier blog article, Microsoft Teams is not only a great team collaboration application with built-in intelligent communications, its also a powerful extensible platform that allows applications to be embedded within teams channels that make collaboration even richer and customizable. As of today, Microsoft Teams already contains hundreds of 3rd party apps published in the Teams store which users can easily install and add to their channels so that everyone in the team can leverage and use. It's also very simple to publish custom built apps and make it available in Teams. This blog posts walks through the steps publishing of a chat bot that can help answer user questions about the upcoming Microsoft Build Conference 2019 from May 6-8 at the Washington State Convention Center, Seattle WA. No coding is required to build this bot and in addition to MS Teams, we can even connect the bot to other additional chat services such as Telegram, Skype and Facebook Messenger
For this walkthrough we first need to have an Azure subscription and licenses to run MS Teams. Free trial Azure subscriptions are available at https://azure.microsoft.com/en-us/free/. To begin, we first login to the Azure portal and on the dashboard create a new "Web App Bot" resource. This will bring up the following screen as shown below:
Picture
To proceed, we simply click on the "Create" and which will allow us to fill in some details of our Web App Bot:
Picture
As shown above, for this walkthough we'll use the name 'msbuild2019bot' which fortunately is still available at the time of this writing, choose the correct Subscription, use an existing resource group 'bk612' (or we can also create a new resource group), select the location closest to us (in this case SouthEast Asia), use the S1 Pricing tier (or we can also use the F0 tier) and the App name will automatically be chosen for us. The important parameter here is in the Bot template section where we need to select the "SDK v3" version and the "Question and Answer" archetype. Further down we can choose an existing "App service plan/Location" (or we can create a new one) and create new Azure Storage for our bot with the auto-created name, turn off Application Insights for now, and lastly choose to auto-create the Microsoft App ID and password. This is shown below:
Picture
With this, we can proceed to click the "Create" button to let Azure create our bot which will take some time. Azure will first validate our parameters to make sure everything is correct and then proceed to create the bot. This can be seen in the notifications area in of the Azure Portal:
Picture
While waiting for our bot to be created, we can head over to the QnAMaker at https://www.qnamaker.ai/ to build the knowledge base for our bot. When logging in, we use the same Microsoft account that we used for Azure and proceed to click on the "Create knowledge base" tab on the top. Since we're doing this for the first time, QnAMaker requires us to first create a QnA Service in Azure as shown below:
Picture
To proceed we click on the "Create a QnA service" button which will pop out another window in Azure portal that allows to define the QnA service. Here we can specify some parameters including the name 'bksgqnasvc' which is not already being used, select the F0 pricing tier which can be modified later if we want, next we leave the Location and Resource group parameters as defaults but we select the Search Pricing tier of B (15 indexes) since this will allow us to build more knowledge bases in the future for other bots. Finally we click on the "Create" button as shown below and Azure will go ahead and deploy the service for us which make take several minutes.
Picture
Once Azure has finished creating our QnA Service, we can head back to http and hit the "Refresh" button. This will allow us to select the Azure tenant, subscription and QnA service for us to build the knowledge base as shown below:
Picture
Next, we can proceed to specify a name and build the knowledge base and the QnA Maker allows us to do this very easily by adding web URLs that contain question and answers. It also allows us to add this information manually but for this walkthrough, Microsoft also provides a MS Build 2019 FAQ URL at https://www.microsoft.com/en-us/build/faq that we can simply add:
Picture

We can also specify the personality of our bot and finally click on the button to Create the KB:
Picture
QnA Maker will parse the URL that we provided and start building the knowledge base. Once completed it will display a list of all the questions and answers that it parsed from the URL:
Picture
Finally we can select the "Publish" tab  and click the Publish Button to publish our knowledge base:
Picture
When successful, QnA Maker will provide some important information such as the first line containing the Knowledge base ID, followed by the host URL and Authorization key that we'll need to use for our bot. Its best to copy this information to a text file for use later:
Picture
Next we head back to Azure portal and navigate to the Application Settings for our Bot. Here we can find three parameters that we need to enter from the infomration that we got from the previous step. On the "QnAAuthKey" we need to enter the authorization key, "QnAEndpointHostName" is our host URL and the "QnAKnowledgebaseId" is our Knowledgebase ID. After entering these 3 parameters we can click the save button and our bot is now connected to the QnA service with the correct knowledge base:
Picture
To test our newly created bot, we can click on the "Test in Web Chat" menu in the properties pane which will allow us to chat with the bot directly and see the results. This is a very useful and easy way to make sure our bot is working properly before we proceed to connect the bot to chat channels such as MS Teams:
Picture
Now that our bot is working we can proceed to connect with MS Teams by selecting the "Channels" properties tab. From here we select the MS Teams icon in the "Add a features channel" section:
Picture
Next we just save our channel and we should see it running:
Picture
Picture
To test this bot in Teams immediately, we can simply click on the Microsoft Teams link in the channels and it will automatically launch MS Teams and allow us to chat with our bot as shown below
Picture
Note that if this fails, it may be due to side loading of external apps is not enabled in which case we can head over to the Microsoft 365 admin portal  and enable the necessary setting as shown below:
Picture
To make our newly created Bot to other Teams users, we can head over to the Teams application and start App Studio (download from the Teams Apps store if not already done so). In App Studio we select "Manifest editor" and click on "Create a new app"
Picture
This allows us to create a JSON manifest for our bot so that it can be loaded by other Teams users. Most of the fields in the App Details section are pretty self-explanatory except for the ID which can just click on the "Generate" button to create a new random ID
Picture
Picture
In the "Capabilities" section is where we define out bot details. Select "Bots" on the left, followed by "Setup" and then "Existing Bot" and we can enter the correct parameters. The only important field here is the "Name" which we can be anything we want, followed by the MS App ID which we need to get from the Application Settings of our Bot in Azure portal:
Picture
We need to copy this App ID and enter it into the manifest in the 2nd text box field. We'll select both Personal and Team Scope and then click Save to complete:
Picture
The final step is to distribute our bot and under the "Finish" section we select "Test and distribute" where we can directly install the bot into Teams or download and save the app package for distribution:
Picture
Clicking on the "Install" button allows us to add the bot to my own account or to a Team within MS Teams:
Picture
Now that we've added the bot to MS Teams we can chat with it:
Picture
We can also download and save the package as a zip file which we can distribute to other uses to upload as a custom app in the Store tab in MS Teams.This concludes the walkthrough of this blog post.
Picture
6 Comments
Antonio Gonzalez
3/25/2020 08:22:25 pm

When creating the bot, the "Questions and answers" template does not appear, is it because I have the trial license?

Reply
Brennon link
4/2/2020 04:58:13 pm

Hi Antonio

You can now create the bot directly from QnA Maker and publish it to Azure. Go to https://aka.ms/abs/templates/qnabot to get started

Reply
Antonio Gonzalez
5/25/2020 01:10:56 pm

Hola, gracias por la publicación, me ha servido mucho.
Tengo un par de duas mas, ¿se pueden cachar las preguntas que hace el usuario y que no tienen respuesta?
¿En teams existe la posibilidad de que se pueda usar la aplicacion sin necesida de intalar desde la tienda ? Gracias

Reply
alvishnu link
8/28/2021 01:20:39 am

I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it. I can also refer you to one of the Best Quiz Maker Chatbot Services in Hyderabad.

Reply
alvishnu link
1/25/2022 02:48:20 am


I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it. I can also refer you to one of the Best Edubot Chatbot Services in Hyderabad.

Reply
Vinu link
3/21/2022 12:46:01 am


I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it. I can also refer you to one of the Best AI Chatbot Services in Hyderabad.

Reply

Your comment will be posted after it is approved.


Leave a Reply.

    Picture
    Picture

    Important Links

    Microsoft Teams Docs
    Microsoft Learn

    ​Microsoft MVP Blogs

    Michael Tressler’s Blog
    Michael’s MTR Quick Tip Videos
    Jimmy Vaughan’s Blog
    Jeff Schertz
    Adam Jacobs
    James Cussen
    ​Damien Margaritis

    Archives

    September 2022
    August 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    June 2021
    April 2021
    March 2021
    December 2020
    October 2020
    September 2020
    August 2020
    April 2020
    March 2020
    February 2020
    January 2020
    December 2019
    November 2019
    October 2019
    September 2019
    August 2019
    July 2019
    March 2019
    November 2018
    October 2018
    September 2018
    August 2018
    June 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    August 2017
    July 2017
    April 2017
    March 2017
    February 2017
    January 2017
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    January 2016
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    April 2014
    March 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013
    December 2012
    November 2012
    September 2012
    August 2012

    Categories

    All
    Edge
    Exchange 2013
    Hybrid
    Lpe
    Lync 2010
    Lync 2013
    Mobility
    Oauth
    Office365
    Polycom
    Ucs

    RSS Feed

    This website uses marketing and tracking technologies. Opting out of this will opt you out of all cookies, except for those needed to run the website. Note that some products may not work as well without tracking cookies.

    Opt Out of Cookies