adaptive.run TECH BLOG

Cloud can be tricky sometimes. Find out what scenarios we've ran into that are worth being mentioned and explained.

Digital online assistants with Azure Bot Services

Level: 300
Publishing date: 24-Apr-2020
Author: Catalin Popa

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

Start by creating a "Web App Bot" resource in Azure:

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.

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.

adaptive.run

Transform your business.
Run adaptive.

Contact

Phone: +40 72 444 3842
Email: hello@adaptive.run

© Copyright  2019-2024 adaptive.run- All Rights Reserved