Every SharePoint application has a FAQ page where user can find the questions and answers on the common queries about the application. Users might find it cumbersome to find the answers by search all through the FAQ pages. To overcome this difficulty, Microsoft introduced a bot framework where user can ask their questions and bot will reply back with the answers and the knowledge base will be utilized to pre configure the QnA pair.
The first step is to create cognitive services, which requires Azure Subscription to create the cognitive and bot services.
Required access to https://www.qnamaker.ai/ (Azure account should have contributor access, Contributor access user will get access to qnamaker automatically)
Creating Cognitive Service in Azure Portal:
1. Login to Azure portal.
2. From All services, search for Cognitive services.
3. Click on Add and choose QnA Maker.
4. Create QnA Maker with necessary inputs like Name, Subscription, App name and Pricing tier.
Creating Knowledge Base(kb):
1. Once Cognitive service is created, go to https://qnamaker.ai
2. Sign in using the same account and choose create a knowledge base tab. Follow the steps as given in the above mentioned url to create a new knowledge base.
3. Skip step 1 as QnA Maker has been created already.
4. Connect QnA service to new kb by selecting Microsoft Azure Directory ID, Azure Subscription name and created QnA service name as given in step 2.
5. Give a name to new kb as given in step 3.
6. Can Insert a file or SharePoint Library URL where we have prebuilt FAQ. If we don’t have prebuilt FAQ, skip step 4 and create Knowledge base. The questions and answers can be added later.
7. New kb can be found under My Knowledge bases tab.
8. Open kb and click Add QnA pair to add questions and answers
Note: Multiple questions can be given to same answer.
9. Once Questions and answers are completed, click on ‘Save and Train’ to save the knowledge base.
10. Test button can be used to test QnA.
11. Publish The Knowledge base by clicking Publish tab.
12. It will be used later to connect the bot with knowledge base. The next step is creation of bot service.
Creating BOT service:
1. Go back to Azure portal.
2. Search for BOT service from All services
3. Click Add, select web app bot and create bot service with unique name.
4. While creating Bot choose Bot Template as Basic (C#), SDK language as C# and template as Question and Answer.
5. Finally click Create to create BOT.
Connecting Knowledge base to BOT:
1. Go to https://qnamaker.ai -> My Knowledge Bases Tab -> Click on ‘View Code’ on respective KB
2. Get QnAKnowledgebaseId, QnAEndpointHostName and QnAAuthKey.
3. Go back to Azure portal -> Bot Services -> Choose your Bot -> on the right blade scroll down to see Application Settings.
4. Enter details (QnAAuthKey, QnAEndPointHostName, QnAKnowledgenbasedid) obtained from View Code.
5. Testing can be done using Test in Web Chat option.
6. If it is working fine, then that’s all. Now we are ready to use the BOT anywhere in the site.
Integrating BOT in a site:
1. Go back to Azure portal -> Bot Services -> Choose your Bot -> on the right blade scroll down to choose channels.
2. Select Web Chat and edit it to get embed code
3. Secret key can be obtained using Show option and replace YOUR_SECRET_HERE with obtained secret key in the Embed code.
4. Create a new site page in the site, click on </> Embed and paste iframe embed code here (An iframe is used to display a web page within a web page).
5. Now the chat BOT can be used in a site.
6. By default, the message will not be displayed with this configuration so we need to tweak the code to get the greet message.
7. Go back to Azure portal -> Bot Services -> Choose your Bot -> on the right blade scroll down to select Build.
8. Click on Open Online Code Editor
9. Click Messagescontroller.cs under Controllers and enter the mentioned script with message that to be displayed while opening chat.
10. Now you are ready to use your bot with default message.
Hope this helps!