Create AI Chatbot using Microsoft Bot Framework (Part 2)
In the last post, we have built a Q&A service using Microsoft QnA Maker & have published it. In this post, we will look at how to build a bot that uses the QnA service. Just to recap, Azure Bot Service which provides an integrated environment that is purpose-built for bot development, enabling us to build, connect, test, deploy, and manage bots, all from one place. It is powered by Microsoft Bot Framework and Azure Functions, which means that the bot will run in a serverless environment on Azure that will scale based upon demand.
Following is an outline of this post :
- Create Azure service bot.
- Enable Web chat channel on the bot.
- Embed the webchat on the website.
Pre-requisites:
- Microsoft Account for generating AppID for your bot.
- Microsoft Azure subscription to use Azure Bot service.
Now we will head over to the Azure management portal, once you log in under Data + Analytics category, and select Bot Service.
- In the Bot Service blade, provide the required information, and click Create to create the bot service and deploy it to the cloud.
- Set App name to required bot’s name. The name is used as the subdomain when the bot is deployed to the cloud (for example, demoqnamaker.azurewebsites.net).
- Select the subscription to use.
- Select the resource group and location. Either you can create new or use existing.
- On the next page, create an app ID and password for your bot, so that it will be able to authenticate with the Bot Framework.
- On click of ‘Create Microsoft App ID and Password’, click Generate an app password to continue.
- Copy and store the password that is shown, and then click Ok.
- Click Finish and go back to Bot Framework.
- Back in the Azure Portal, the app ID field is now auto-populated for you. Paste the password that you copied (in the step above) into the password field.
- Choose the programming language to develop the bot, here I have opted for C#. Also, there is an option to choose the Bot template, make sure to select it as ‘Question and Answer’
- Now we have to select the service which we have created in the last post, here it’s ‘Demo’ and then click Ok.
- When the bot service finishes generating the bot, the Azure editor will contain the bot’s source files. At this point, the bot has been created, registered with the Bot Framework, deployed to the cloud, and is fully functional.
- Now that the bot is up and running in the cloud, we can try it out by typing a few messages into the built-in chat control that’s located to the right of the code editor in the portal. The bot responds to each message by echoing back your message prefixed with the text You and response by the name of your bot.
- The next step is to enable the webchat channel, this can be done by clicking on the ‘Channels’ tab on the top bar. Once you’re in channel settings, you can customize the look and feel of the button and you can get embed code at the bottom left portion of the page.
- Once you have the embed code, the same can be embedded to the page/website you wish.
Now that you’ve created your first bot, there is more to explore. Just recap of what we have done
- Create Q&A knowledge base.
- Create Azure service bot.
- Enable Web chat channel on the bot.
- Embed the webchat on the website.
If you want to explore more, please check the links below.
- QnA Maker
- Bot Builder Samples GitHub repository
- Bot Builder SDK for .NET
- Bot Builder SDK for Node.js
I hope you have enjoyed learning along with me. If you have questions, please share them in the comments section.
Like this post? Don’t forget to share it!
Average Rating