Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

How to Build a Basic Chatbot Using Microsoft Azure

May 1, 2020 • 8 Minute Read

Introduction

Chatbots are nothing new. In fact, they have been around in some form since the '60s. But those chatbots were nothing like what we have today with machine learning (ML) algorithms, which allow them to learn how to interact with users more effectively over time. Many companies are competing with their own variants to stand out from the pack, like Microsoft with its Azure platform.

This guide covers setting up a chatbot using Azure Bot Service.

Creating the Basic Bot

Create your account and log in to Azure Portal.

Next, click Create a resource.

Click AI + Machine Learning on the left, then the Web App Bot icon and fill in the required information. If you haven't set up any other Azure services, most of these fields will be blank.

Click Create new to create a resource group. You can have one resource group with the free plan. Resource groups are containers that hold related resources such as apps that share a lifecycle.

Next, set up a Bot template. Choose whether the bot's SDK language will be C# or Node.js and whether it will be an Echo Bot or a Basic Bot. For anything other than a bot that echoes back the user's messages, choose Basic Bot.

View more samples will take you to the Bot Framework samples repository where you can see examples of chatbots you can create with custom code.

To create your QnA Bot, you will first need to deploy the basic bot in Azure and create a knowledge base (KB) for it.

You also need to create an account for Language Understanding (LUIS), which is a cloud API service. Choose its location and an App service plan, and click Create.

The Location is related to where the resource group is hosted, meanwhile the Luis App Location relates to where you will author and publish the knowledge base.

There are three main regions and each have separate keys and Luis portal URLs. Use eu.luis.ai for Europe, luis.ai for US and au.luis.ai for Australia. You can export and import apps to different regions, but that is less important for the purposes of just a chatbot hosted on a page. Host where you want to target a user base.

You will get a notification when your basic bot is deployed. From there it needs to be turned into a QnA Bot.

Click on your bot's name in the All resources menu to test it in a web chat

Making a QnA Bot

Create a Knowledge Base

A knowledge base (KB) is the information hub the chatbot will scan for relevant information when answering questions. Head over to qnamaker.ai to start this process.

Click Create a knowledge base and follow the prompts.

Do not forget to Create a QnA service in step one and connect it to your KB in step two before creating the KB fully.

A new tab will appear, but go back to the KB creation tab.

After deploying and connecting your QnA service, go through the rest of the KB setup prompts and populate your KB with documents or a URL.

Enable the multi-turn extraction from URLs, .pdf or .docx files option. This option allows your chatbot to ask follow-up questions. It also allows the chatbot to scan entire pages for later feedback to the user.

Under the Default answer text box, pick any answer you want your bot to use if it cannot find an answer.

After a couple other basic prompts, you will be given a Chit-chat option for you to tailor your bot to fit a particular style of language or mood.

Next, click Create your KB to see the contents of your KB in three sections: Context, Question, and Answer.

Under the question section you can add your own phrasing, add follow-up prompts to make your bot more unique, and direct your chatbot to provide a link to another page if it can't find an answer.

To start training your bot, click Save and train or Test. Before training, you will have to save.

Training your bot basically means saving any preferences you have added and helping the algorithm learn what you desire from the bot during interactions. The more examples you give, the more effective it will become.

Once you are satisfied with your bot, click PUBLISH. This will move the content from the test to production index in Azure search. You will have access to it via QnA Maker service. You will see a block of code you can copy and use later on your site or messenger for the HTTP request.

Click View.

Click Test in Web Chat in the Azure Bot services directory and ask the bot questions. At this point, the bot and KB should be connected.

You can go back to the QnA Maker website to edit your questions, answers, and follow-up questions. You can even add access control and tags to your QnA service, which are useful if you have more than one person running bot service and want to know who is running each bot.

It is worth including as many alternative questions as possible and different ways they can be asked so your chatbot can learn to better understand users and find answers.

Deploying your Chatbot

The QnA service or KB is listed under Cognitive Services in the Azure portal. You can deploy your bot from here.

Go to the channels section in the Web App Bot service to deploy your bot to channels such as e-mail, Facebook, Slack, Telegram or Skype. You will need an account on most channels you deploy to.

Here is an interesting resource on how this works and is quite unique as most bot services focus on website chat or Facebook Messenger.

Click Edit in the Connect to channels section of your Web App Bot to get the iframe code that you can then paste into the HTML or header section of your site for your chat bot widget to appear.

Conclusion

Now you have a sense of the process of creating a QnA bot within Microsoft’s Azure service. There are a lot more options that you can work with if you are a developer, such as creating bots locally using JavaScript or Python-based templates.