您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

关于 Azure 机器人服务About Azure Bot Service

适用于: 是SDK v4 是SDK v3 APPLIES TO: yesSDK v4 yesSDK v3

Azure 机器人服务和 Bot Framework 提供的工具可用于在一个位置构建、测试、部署和管理智能机器人。Azure Bot Service and Bot Framework provide tools to build, test, deploy, and manage intelligent bots all in one place. 通过使用 SDK、工具、模板和 AI 服务提供的模块化可扩展框架,开发人员可以创建可使用语音、自然语言理解、问题和答案处理等功能的机器人。Through the use of modular and extensible framework provided by the SDK, tools, templates, and AI services developers can create bots that use speech, understand natural language, handle questions and answers, and more.

什么是机器人?What is a bot?

机器人提供的体验让你感觉不太像在使用计算机,而更像是在与人打交道,或者至少是在与智能机器人打交道。Bots provide an experience that feels less like using a computer and more like dealing with a person - or at least an intelligent robot. 可以使用机器人将简单的重复性任务(例如订餐或收集个人资料信息)转移给不再需要直接人为干预的自动化系统来完成。They can be used to shift simple, repetitive tasks, such as taking a dinner reservation or gathering profile information, on to automated systems that may no longer require direct human intervention. 用户使用文本、交互卡和语音与机器人聊天。Users converse with a bot using text, interactive cards, and speech. 机器人交互可以是快速的问答式交互,也可以是复杂的聊天,通过聊天以智能方式提供对服务的访问权限。A bot interaction can be a quick question and answer, or it can be a sophisticated conversation that intelligently provides access to services.

机器人很像现代 Web 应用程序,驻留在 Internet 中,使用 API 发送和接收消息。Bots are a lot like modern web applications, living on the internet and use APIs to send and receive messages. 机器人中的内容差异很大,具体取决于机器人的类型。What's in a bot varies widely depending on what kind of bot it is. 现代机器人软件依赖一系列技术和工具,在各种平台上提供日益复杂的体验。Modern bot software relies on a stack of technology and tools to deliver increasingly complex experiences on a wide variety of platforms. 不过,简单的机器人可以只接收消息并将其回显给用户,基本不需要编写代码。However, a simple bot could just receive a message and echo it back to the user with very little code involved.

机器人可以完成其他类型的软件可以完成的任务 - 读写文件、使用数据库和 API,以及执行常规的计算任务。Bots can do the same things other types of software can do - read and write files, use databases and APIs, and do the regular computational tasks. 使机器人不同于其他软件的是,它们使用的通信机制通常是人与人之间通信才会使用的。What makes bots unique is their use of mechanisms generally reserved for human-to-human communication.

Azure 机器人服务和 Bot Framework 提供:Azure Bot Service and Bot Framework offer:

  • 用于开发机器人的 Bot Framework SDKBot Framework SDK for developing bots
  • 涵盖端到端机器人开发工作流的 Bot Framework 工具Bot Framework Tools to cover end-to-end bot development workflow
  • Bot Framework Service (BFS),用于在机器人和通道之间发送和接收消息和事件Bot Framework Service (BFS) to send and receive messages and events between bots and channels
  • Azure 中的机器人部署和通道配置Bot deployment and channel configuration in Azure

另外,机器人可能使用其他 Azure 服务,例如:Additionally, bots may use other Azure services, such as:

  • 用于生成智能应用程序的 Azure 认知服务Azure Cognitive Services to build intelligent applications
  • 用于云存储解决方案的 Azure 存储Azure Storage for cloud storage solution

构建机器人Building a bot

Azure 机器人服务和 Bot Framework 提供一组集成的工具和服务来加快此过程。Azure Bot Service and Bot Framework offer an integrated set of tools and services to facilitate this process. 请选择最喜欢的开发环境或命令行工具以创建机器人。Choose your favorite development environment or command line tools to create your bot. 提供用于 C#、JavaScript 和 Typescript 的 SDK。SDKs exist for C#, JavaScript, and Typescript. (用于 Java 和 Python 的 SDK 正在开发。)我们提供适合各个机器人开发阶段的工具,方便你设计和生成机器人。(SDKs for Java and Python are under development.) We provide tools for various stages of bot development to help you design and build bots.

机器人概述

计划Plan

与任何类型的软件一样,若要创建成功的机器人,必须全面了解目标、流程和用户需求。As with any type of software, having a thorough understanding of the goals, processes and user needs is important to the process of creating a successful bot. 在编写代码之前,请参阅设计指南 ,了解最佳做法并确定机器人的需求。Before writing code, review the bot design guidelines for best practices and identify the needs for your bot. 可以创建简单的机器人,也可以让机器人包含较复杂的功能,例如语音、自然语言理解和问题解答。You can create a simple bot or include more sophisticated capabilities such as speech, natural language understanding,and question answering.

构建Build

机器人是一项 Web 服务,可实现聊天式界面并与 Bot Framework Service 通信,以便发送和接收消息和事件。Your bot is a web service that implements a conversational interface and communicates with the Bot Framework Service to send and receive messages and events. Bot Framework Service 是 Azure 机器人服务和 Bot Framewrk 的一个组件。Bot Framework Service is one of the components of the Azure Bot Service and Bot Framework. 可在任意数目的环境和语言中创建机器人。You can create bots in any number of environments and languages. 可在 Azure 门户中开始机器人开发,也可使用 [C# | JavaScript] 模板进行本地开发。You can start your bot development in the Azure portal, or use [C# | JavaScript] templates for local development.

我们提供其他组件作为 Azure 机器人服务和 Bot Framewrk 的一部分来扩展机器人的功能As part of the Azure Bot Service and Bot Framework, we offer additional components you can use to extend your bot's functionality

FeatureFeature 说明Description 链接Link
添加自然语言处理Add natural language processing 可让机器人理解自然语言、了解拼写错误、使用语音和识别用户的意向Enable your bot to understand natural language, understand spelling errors, use speech, and recognize the user's intent 如何使用 LUISHow to use LUIS
回答问题Answer questions 添加知识库,以更自然的聊天形式回答用户的提问Add a knowledge base to answer questions users ask in a more natural, conversational way 如何使用 QnA MakerHow to use QnA Maker
管理多个模型Manage multiple models 如果使用多个模型(例如 LUIS 和 QnA Maker),在与机器人聊天过程中,机器人能够明智地确定何时使用哪个模型If using more than one model, such as for LUIS and QnA Maker, intelligently determine when to use which one during your bot's conversation Dispatch 工具Dispatch tool
添加卡片和按钮Add cards and buttons 使用除文本以外的媒体(例如图形、菜单和卡片)来增强用户体验Enhance the user experience with media other than text, such as graphics, menus, and cards 如何添加卡片How to add cards

备注

上面的表格不是完整的列表。The table above is not a comprehensive list. 浏览左侧的文章,从发送消息开始,了解更多机器人功能。Explore the articles on the left, starting with sending messages, for more bot functionality.

此外,我们提供命令行工具来帮助你创建、管理和测试机器人资产。Additionally, we provide command line tools to help you to create, manage, and test bot assets. 这些工具可以配置 LUIS 应用、生成 QnA 知识库、生成在组件之间进行调度的模型、模拟聊天,等等。These tools can configure LUIS apps, build a QnA knowledge base, build models to dispatch between components, mock a conversation, and more. 可在命令行工具自述文件中找到更多详细信息。You can find more details in the command line tools readme.

还可以访问各种示例,了解通过 SDK 提供的多项功能。You also have access to a variety of samples that showcase many of the capabilities available through the SDK. 这些特别适用于希望从功能较丰富的示例着手的开发人员。These are great for developers looking for a more feature rich starting point.

测试Test

机器人是复杂的应用,有大量不同的协同工作的部件。Bots are complex apps, with a lot of different parts working together. 就像其他复杂应用一样,这可能会导致出现一些需要关注的 Bug,或者会导致机器人的行为异常。Like any other complex app, this can lead to some interesting bugs or cause your bot to behave differently than expected. 发布前,请先测试机器人。Before publishing, test your bot. 在发布机器人供用户使用之前,我们提供了多种方式来测试机器人:We provide several ways to test bots before they are released for use:

  • 使用模拟器在本地测试机器人。Test your bot locally with the emulator. Bot Framework Emulator 是独立的应用,不仅提供聊天界面,而且提供调试和询问工具来帮助理解机器人的工作方式和工作原理。The Bot Framework Emulator is a stand-alone app that not only provides a chat interface, but also debugging and interrogation tools to help understand how and why your bot does what it does. 此模拟器可以在本地与正在开发的机器人应用程序一起运行。The emulator can be run locally alongside your in-development bot application.

  • Web 上测试机器人。Test your bot on the web. 通过 Azure 门户进行配置以后,机器人也可通过网上聊天界面进行访问。Once configured through the Azure portal your bot can also be reached through a web chat interface. 测试者和其他无法直接访问机器人的运行代码的人员可以通过网上聊天界面访问机器人。The web chat interface is a great way to grant access to your bot to testers and other people who do not have direct access to the bot's running code.

  • 使用 Bot Framework SDK 的 7 月更新对机器人进行单元测试Unit Test your bot with the July update of Bot Framework SDK.

发布Publish

做好在网上发布机器人的准备以后,请将机器人发布到 Azure 或你自己的 Web 服务或数据中心。When you are ready for your bot to be available on the web, publish your bot to Azure or to your own web service or data center. 若要将机器人嵌入站点或聊天通道,第一步是获取公共 Internet 上的地址。Having an address on the public internet is the first step to your bot coming to life on your site, or inside chat channels.

连接Connect         

将机器人连接到 Facebook、Messenger、Kik、Skype、Slack、Microsoft Teams、Telegram、短信、Twilio、Cortana 和 Skype 等通道。Connect your bot to channels such as Facebook, Messenger, Kik, Skype, Slack, Microsoft Teams, Telegram, text/SMS, Twilio, Cortana, and Skype. 在通过所有这些不同的平台发送和接收消息的过程中,Bot Framework 完成大多数必需的工作 - 不管连接到的通道的数目和类型如何,机器人应用程序都会收到统一且规范化的消息流。Bot Framework does most of the work necessary to send and receive messages from all of these different platforms - your bot application receives a unified, normalized stream of messages regardless of the number and type of channels it is connected to. 有关如何添加通道的信息,请参阅通道主题。For information on adding channels, see channels topic.

评估Evaluate

使用 Azure 门户中收集的数据确定改善机器人功能和性能的机会。Use the data collected in Azure portal to identify opportunities to improve the capabilities and performance of your bot. 可以获得服务级和检测数据,如流量、延迟和集成。You can get service-level and instrumentation data like traffic, latency, and integrations. 此外,Analytics 还提供有关用户、消息和通道数据的聊天级报告。Analytics also provides conversation-level reporting on user, message, and channel data. 有关详细信息,请参阅如何收集分析数据For more information, see how to gather analytics.

后续步骤Next steps

请查看这些机器人案例研究,或者单击下面的有关如何创建机器人的链接。Check out these case studies of bots or click on the link below to create a bot.