Introduction

If you haven’t had much programming experience before, building a conversational bot and connecting it to various channels may sound like a difficult task. However, with the Azure Bot Service, Microsoft Language Understanding Intelligent Service (LUIS) and Microsoft Bot Framework, you can finish all the work within a few hours. In this blog post I am going to walk through how to:

· Register a bot in Azure Bot Service

· Train your custom language intelligence application using LUIS

· Design the bot directly in Azure editor

· Connect the Bot to different channels in Microsoft Bot Framework

Setting up the bot in Microsoft Azure:

Microsoft Azure is a cloud computing service that allows you to build, test and publish applications using the Azure portal. The first thing you need to do is to sign in/create a new account in https://azure.microsoft.com/en-us/?v=17.14.

To start building the chat bot, press the green plus button on the top-left corner and choose ‘Bot Service’ under ‘Data + Analysis’:

Once you fill in the app name and the location, press Create. It might take a while to deploy the bot. Here I named the demo bot ‘mspdemobot’ and chose South-Central US as the location.

A notification will be sent when deployment succeeds, and you will be greeted with the following screen. To get the App ID and password, simply click on the blue button to register your bot. Here, we choose Nodejs as the language and Language Understanding as the template for the demo bot. After pressing ‘Create Bot’, a window will open to ask you to connect Azure Bot Service to LUIS:

After everything is set up, you can edit your bot directly in Azure editor. Azure also allows you to integrate with BitBuckey, GitHub and Visual Studio Team Service. You can find tutorials on continuous deployment here: https://docs.microsoft.com/en-us/azure/app-service-web/app-service-continuous-deployment:

Go to https://www.luis.ai/welcome and sign in using the same account you used previously for Azure Bot Service. You can see that under My Apps section, there is a new application called ‘mspdemobot’:

Training Your Bot with LUIS:

To build a conversational bot, we want our bot to understand the intentions of the sentences and extract important information. This is where Microsoft Language Understanding Intelligent Service comes in. It reduces the difficulty of building an intelligent bot by allowing us to customize our own language-understanding model in an intuitive way.

To create a new application, click ‘New App’ and fill in the name and culture (from 16 different languages to choose from) of your application. We are going to mainly work on the Intents and Entities in LUIS. Once you click on ‘Intent’, you can create different categories for your custom language understanding model. For example, we can start with the most basic category ‘Greeting’:

After the intent is created, you will be directed to a page where you can add in a new utterance. In this case, possible new utterances could be ‘Hey’, ‘How are you doing?’, or ‘Hello’ etc.

Sometimes, we need to work on a specific token to continue the conversation, or to complete a certain task. To achieve this, we need to go to the Entities page. There are several prebuilt entities available, such as age, URL, and email address. You can also choose a package of intent and entities for different situations by adding prebuilt domain entities. You can also add in your own custom entities to suit your need. To help your application understand which part of the utterance belongs to which entities, you only need to go back to the utterance page and click on the words you need. In the following screenshot, ‘London’ is selected as location entity in the ‘AskWeather’ intent:

Now let’s move to the testing part. In Train & Test page you can test specific utterances with your newest model. The right-hand side shows the result produced by current version, which consists of the intent name and the corresponding score. The score is the possibility of the intent that your test utterance belongs to. Using this, you could test some edge case and optimize your model based on the outcome.

The more utterances you enter, the more accurate the results will be. After you finish testing, publish your LUIS app and you are good to go.

Coding Your Bot:

Once you open the Azure portal and go to the bot service page of your bot, you can code and test your bot directly in Azure editor. In here, we use the ‘intent.matches’ function to let the bot do different things based on users’ intentions. A very simple example is the intent ‘Greeting’, we simply detect user’s intent and reply with a sentence:

Based on this, we can start coding more complicated things. We are going to code a bot with the ability to understand user’s intentions and start a hangman game when the intent ‘StartGame’, is detected.

To build a hangman bot, you can refer to the blog post by Paul Seal, which explains the process using Nodejs with sample code: http://www.codeshare.co.uk/blog/how-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft-bot-framework/.

After the bot is finished you can test it directly in the Azure portal. In my demo bot, I added in more match functions to show that the bot can understand different intentions by connecting to the LUIS API. Here are the screenshots of when different intentions are detected; the bot successfully detects the intentions and classifies ‘London’ as a ‘location’ entity. The developer could design more complicated features by extracting the entities from the argument.

You could find out how to extract an entity as well as other functions in the reference library: https://docs.botframework.com/en-us/node/builder/chat-reference/modules/_botbuilder_d_.html.

Connecting Your Bot to Different Channel:

You can easily connect your bot to Skype, Messenger, Bing etc. by simply adding them as the channel of your bot. Go to Microsoft Bot Framework and your bot should be connected to Web Chat and Skype by default:

There are many different channels you can connect your bot to. Once you click on a channel, there will be step by step guide to help you to configure the channel. Simply follow the instructions and most of them should be as easy as copy and paste. The second icon is Cortana, which is an intelligent agent for Windows 10. If you want to provide Cortana with new capabilities using the bot you built, you could refer to this blog post: https://www.robinosborne.co.uk/2017/05/14/building-your-first-botframework-based-cortana-skill/.

How to Build a Chat Bot Using Azure Bot Service and Train It with LUIS的更多相关文章

  1. [Windows Azure] Building worker role B (email sender) for the Windows Azure Email Service application - 5 of 5.

    Building worker role B (email sender) for the Windows Azure Email Service application - 5 of 5. This ...

  2. [Windows Azure] Building worker role A (email scheduler) for the Windows Azure Email Service application - 4 of 5.

    Building worker role A (email scheduler) for the Windows Azure Email Service application - 4 of 5. T ...

  3. [Windows Azure] Building the web role for the Windows Azure Email Service application - 3 of 5

    Building the web role for the Windows Azure Email Service application - 3 of 5. This is the third tu ...

  4. [Windows Azure] Configuring and Deploying the Windows Azure Email Service application - 2 of 5

    Configuring and Deploying the Windows Azure Email Service application - 2 of 5 This is the second tu ...

  5. 【Azure 机器人】微软Azure Bot 编辑器系列(6) : 添加LUIS,理解自然语言 (The Bot Framework Composer tutorials)

    欢迎来到微软机器人编辑器使用教程,从这里开始,创建一个简单的机器人. 在该系列文章中,每一篇都将通过添加更多的功能来构建机器人.当完成教程中的全部内容后,你将成功的创建一个天气机器人(Weather ...

  6. ASP.NET Core在Azure Kubernetes Service中的部署和管理

    目录 ASP.NET Core在Azure Kubernetes Service中的部署和管理 目标 准备工作 注册 Azure 账户 AKS文档 进入Azure门户(控制台) 安装 Azure Cl ...

  7. 如何将Azure DevOps中的代码发布到Azure App Service中

    标题:如何将Azure DevOps中的代码发布到Azure App Service中 作者:Lamond Lu 背景 最近做了几个项目一直在用Azure DevOps和Azure App Servi ...

  8. Azure App Service(一)利用Azure DevOps Pipeline 构建镜像,部署应用程序

    一,引言 起因是前两天项目上做测试,需要我把写好的基于.NET 5 的 Web 测试程序作成 Docker 镜像.当我在本地验证完功能后,准备利用 Docker 构建应用程序镜像的时候,发现系统不支持 ...

  9. Azure Media Service (1) 使用OBS进行Azure Media Service直播

    <Windows Azure Platform 系列文章目录> 今天正好有客户问如何使用OBS进行Azure Media Service直播,我这里简单介绍一下. 先决条件: 1. OBS ...

随机推荐

  1. PHP 中的Trait

    概述 在PHP中有一种代码复用的技术, 因为单继承的问题, 有些公共方法无法在父类中写出, 而 Trait可以应对这种情况, 它可以定义一些复用的方法, 然后在你需要使用的类中将其引入即可. 刚开始的 ...

  2. 荣耀MagicBook黑苹果(i7)High Sierra 10.13.6

    这里有大佬维护的新版本EFI,对应10.14.4:https://github.com/hjmmc/Honor-Magicbook ---------------------------------- ...

  3. #WEB安全基础 : HTML/CSS | 0x5a标签拓展和class、id属性的使用

    a标签不只是能链接到其他网页,也能链接到网页中的元素 class属性让你用CSS对特定的元素进行修饰 这些是一个网页设计者的有力武器 这节课还是一个index.html文件   以下是代码 <h ...

  4. 1.SDL介绍

    01.什么是SDL SDL是微软提出的一种软件开发安全生命周期管理的一种最佳安全实践,全称为Security Development Lifecycle. SDL是微软软件开发安全保障流程,结合了软件 ...

  5. gitbook 入门教程之使用 gitbook.com 在线开发电子书

    gitbook 官网是官方提供的图书托管的在线平台,分为新版官网(需要FQ) https://www.gitbook.com/ 和旧版官网(无需FQ) https://legacy.gitbook.c ...

  6. 数据库之redis篇(1)—— redis数据库安装,简单使用

    简介 reids,由Salvatore Sanfilippo写的一个高性能的key-value数据库,并且它是非关系型数据库,也就是没有像mysql那样多表链接操作,并且它是是完全开源免费的,遵守BS ...

  7. oracle 10g函数大全--日期型函数

    sysdate [功能]:返回当前日期. [参数]:没有参数,没有括号 [返回]:日期 [示例]select sysdate hz from dual; 返回:2008-11-5 add_months ...

  8. python 词云学习

    词云入门 三步曲 数据获取:使用爬虫在相关网站上获取文本内容 数据清洗:按一定格式对文本数据进行清洗和提取(文本分类,贴标签) 数据呈现:多维度呈现和解读数据(计算,做表,画图) 一 模块的安装 pi ...

  9. c#语法学习

    自动属性.隐试类型.命名参数和自动初始化器. note:这里说的这些,是语法糖.按照一定的格式写,部分代码编译器帮我们实现了, 1.自动属性:自动属性是非常有用的语法糖,帮我我们做了两件事:1.自动帮 ...

  10. Loj 2320.「清华集训 2017」生成树计数

    Loj 2320.「清华集训 2017」生成树计数 题目描述 在一个 \(s\) 个点的图中,存在 \(s-n\) 条边,使图中形成了 \(n\) 个连通块,第 \(i\) 个连通块中有 \(a_i\ ...