Ok, for this recipe you need the following ingredients.
- Access to Microsoft Azure and a subscription doesn’t need to be a pay-as-you-go version, can be MSDN, Visual Studio Enterprise, Trial, etc.
- Sign in to https://www.qnamaker.ai. (This is where you QnA pairs will be stored)
- App Studio in Teams (further down, I will explain how to install the app in Team
Let’s start by creating our QnA.
- Open QnAMaker.ai and create a new knowledge base
- We need a QnAService (which lives on Azure). Click on the button Create a QnA service
- Fill in the details of your Bot
- Pricing Tier. The F tier is free but limited in traffic, the S tier is not free but doesn’t have the limitation the F tier has.
- Define your ResourceGroup. The purpose of a Resource Group is beyond the scope of this article but docs.microsoft.com can help you with this information.
- Define your Search pricing tier. F is free.
- Set your Search location
- Define your App Name
- Define Website location
- Define App insights enabled and its location
- Click Create
- Go back to QnAMaker and refresh.
- Select your Microsoft Azure Directory ID, subscription and Azure QnA Service (the one you just created)
- Name your KB. I am going to use the Microsoft FAQ found on https://www.microsoft.com/en-us/software-download/faq as a setup so my name is Microsoft Download FAQ
- Populate your KB. This can be done by adding a URL like what I am going to do (perfect if you want to use you existing FAQ) or you can upload a file with your QnA pair. I also going to select “Enable multi-turn extraction”, which allows me to have follow-up questions in my bot conversation. Of course your FAQ needs to have this otherwise it will be just a plain QnA setup. More information can be found here.
- Chit-Chat. You can provide a personality to you bot. Since this is going to be a bot that people will use to find information I am going to choose a Caring personality.
- Click on Create your KB. When finished you will see pages of QnA pairs that you adjust, add question or finetune the tone where necessary.
- You can test the QnA pair by using the test button.
- To make it ready for usage in a real bot click Save and Train and publish
- This provide some information you will need when you create the bot.
- POST /knowledgebases/5b0c26a8-490b-4cec-a3b2-251b1d65edc3/generateAnswer
Authorization: EndpointKey c09ff040-8e35-4445-a14e-ac1801b44ab9
Time to Create the brains of the operation
- Login your Azure Portal and search for Bot Services
- Click Create bot service and choose a Web App Bot, finalize by clicking Create
- Fill in all the details like we did earlier. Some interesting information:
- Name: I used the Bot name: AskMeAnythingBot
- Make sure in the Bot template, you select the SDK v3 and Question and Answer. I choose Node.js as the SDK language but since we are not writing code this shouldn’t matter.
- Fill in the rest
- Click Create
- You should get the notification Validation successful. Now have patience until the bot is created.
- We have a bot! When we go in Test in Web Chat and start having a conversation we get the following message. Please set QnAKnowledgebaseId, QnAAuthKey and QnAEndpointHostName (if applicable) in App Settings. Learn how to get them at https://aka.ms/qnaabssetup. This make sense we have not connected the QnA to the bot itself. We need to do this based on the information we got back from QnA maker. In my example:
- Go to Configuration under App Service Settings and add the following configuration. Make sure you replace it with the right information. The information is unique to my setup.
- QnAKnowledgebaseId: 5b0c26a8-490b-4cec-a3b2-251b1d65edc3
- QnAAuthKey : c09ff040-8e35-4445-a14e-ac1801b44ab9
- QnAEndpointHostName : https://askmebotfaq.azurewebsites.net/qnamaker
- Go in the Web Chat again and now you should be able to have a proper conversation with the QnA.
- Next we need to make sure the Bot is ready to accept conversations from Teams. This falls under Channels. Click on Microsoft Teams under featured channel. When you click on Microsoft Teams it will open your Teams client and start a conversation with the bot. This allows you to test the bot inside the Teams chat to see if everything works as wanted.
Make the bot a permanent part of Microsoft Teams
- Install App Studio (or open if already installed). You can find this in the Store in Microsoft Teams
- Go to manifest editor
- Click Create a new App.
- Fill in all the App details
- Click on Bots
- Click on Setup
- Select Existing Bot
- Give it a name and find the MicrosoftAppId under the bot configuration in the Azure Portal and enter it under Connect to a different bot id
- Select the scope of your bot.
- Personal = only in personal chat
- Team = deploy in a channel as well
- Group Chat = add the bot as a member of a group chat.
- Click Save
- Click Test and Distribute
- Click Install and decide in what channel the bot needs to be deployed
This is all you need.
Result in a channel:
Result in a chat:
Click on the Team Icon to share to your Teams Environment