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

为宾馆预订构建聊天机器人

Azure
机器人服务
Application Insights
语言理解
Active Directory 外部标识
应用服务
认知服务

此示例方案通常适用于想要将对话聊天机器人集成到应用程序中的企业。This example scenario applies generally to businesses that want to integrate a conversational chatbot into applications. 具体而言,此方案显示了一个用于宾馆的 c # 聊天机器人,以允许客户通过 web 或移动应用程序检查可用性和书籍便利。Specifically, this scenario shows a C# chatbot for a hotel to allow customers to check availability and book accommodation through a web or mobile application.

除了酒店预订以外,此聊天机器人可用于各种商务设置。Beyond hotel booking, this chatbot could be used in a wide range of commerce settings. 例如,聊天机器人可以让客户查看餐馆的取出菜单并下订单。For example, the chatbot can enable customers to review the take-out menu of restaurant and place an order. 或者,聊天机器人可以使照相工作室的客户搜索和订购打印。Or, the chatbot can enable customers of a photography studio to search for and order prints. 通常,企业雇用和培训客户服务代理来响应这些类型的客户请求。Traditionally, businesses hire and train customer service agents to respond to these types of customer requests. 因此,客户需要等待一个代表提供协助。As a result, customers wait until a representative is available to provide assistance.

使用 Azure Bot 服务语言理解语音 服务,企业可以使用可缩放的机器人来处理常见客户请求。With Azure Bot Service and Language Understanding or Speech services, businesses can use scalable bots to handle common customer requests.

宾馆预订机器人的体系结构Architecture for hotel booking bot

体系结构概述:会话聊天机器人和会话聊天机器人中涉及的 Azure 组件

本方案涉及的对话式聊天机器人充当酒店接待。This scenario covers a conversational bot that functions as a concierge for a hotel. 数据流经方案的情形如下所示:The data flows through the scenario as follows:

  1. 客户通过移动或 Web 应用访问此聊天机器人。The customer accesses the chatbot with a mobile or web app.
  2. 使用 Azure Active Directory (Azure AD) B2C (企业到消费者) ,对客户进行身份验证。Using Azure Active Directory (Azure AD) B2C (business-to-consumer), the customer is authenticated.
  3. 与机器人服务交互,客户请求有关酒店可用性的信息。Interacting with the Bot Service, the customer requests information about hotel availability.
  4. 认知服务通过处理自然语言请求来理解客户通信。Cognitive Services processes the natural language request to understand the customer communication.
  5. 客户对结果感到满意后,bot 会在 SQL 数据库中添加或更新预订或预订。After the customer is happy with the results, the bot adds or updates the reservation or booking in a SQL database.
  6. Application Insights 在整个过程中收集运行时遥测,以帮助 DevOps 团队改善机器人性能和使用情况。Application Insights gathers runtime telemetry throughout the process to help the DevOps team improve bot performance and usage.

组件Components

  • Azure Active Directory (Azure AD) 是 Microsoft 的基于云的多租户目录和标识管理服务。Azure Active Directory (Azure AD) is Microsoft's multitenant cloud-based directory and identity management service. Azure AD 支持 B2C 连接器,使你能够按其外部 Id (如 Google、Facebook 或 Microsoft 帐户)识别用户。Azure AD supports a B2C connector allowing you to identify users by their external IDs, such as Google, Facebook, or a Microsoft account.
  • 应用服务允许你采用所选编程语言生成和托管 Web 应用程序,无需管理基础结构。App Service enables you to build and host web applications in the programming language of your choice without managing infrastructure.
  • 机器人服务提供的工具可用于生成、测试、部署和管理智能机器人。Bot Service provides tools to build, test, deploy, and manage intelligent bots.
  • 认知服务允许你使用智能算法,以自然的沟通方式来观察、倾听、表述、了解和解释用户需求。Cognitive Services lets you use intelligent algorithms to see, hear, speak, understand, and interpret your user needs through natural methods of communication.
  • SQL 数据库是一种完全托管的云关系数据库服务,可以与 SQL Server 引擎兼容。SQL Database is a fully managed relational cloud database service that provides SQL Server engine compatibility.
  • Application Insights 是可扩展的应用程序性能管理 (APM) 服务,用于监视应用程序(例如聊天机器人)的性能。Application Insights is an extensible Application Performance Management (APM) service that lets you monitor the performance of applications, such as your chatbot.

可用于增强此示例方案的其他组件包括:Other components that could be used to enhance this example scenario include:

  • 用于更改客户如何与机器人进行交互的语音 APISpeech API to change how customers interface with your bot.
  • QnA Maker 从半结构化内容(如 FAQ)快速将知识添加到机器人。QnA Maker to quickly add knowledge to your bot from semi-structured content like an FAQ.
  • 文本翻译 作为一项服务,可轻松地将多语言支持添加到机器人。Translator Text as a service to easily add multi-lingual support to your bot.

注意事项Considerations

可用性Availability

本方案使用 Azure SQL 数据库来存储客户预订项目。This scenario uses Azure SQL Database for storing customer reservations. SQL 数据库包括区域冗余数据库、故障转移组和异地复制。SQL Database includes zone redundant databases, failover groups, and geo-replication. 有关详细信息,请参阅 Azure SQL 数据库可用性功能For more information, see Azure SQL Database availability capabilities.

可伸缩性Scalability

本方案使用 Azure 应用服务。This scenario uses Azure App Service. 可以通过应用服务自动调整运行机器人的实例数。With App Service, you can automatically scale the number of instances that run your bot. 可以通过此功能时刻了解客户对 Web 应用程序和聊天机器人的需求情况。This functionality lets you keep up with customer demand for your web application and chatbot. 有关自动缩放的详细信息,请参阅 Azure 体系结构中心的自动缩放最佳做法For more information on autoscale, see Autoscaling best practices in the Azure Architecture Center.

有关其他可伸缩性的文章,请参阅 Azure 体系结构中心中的 性能效率检查清单For other scalability articles, see the performance efficiency checklist in the Azure Architecture Center.

安全性Security

此方案使用 Azure Active Directory (Azure AD 使用企业对消费者标识管理服务) B2C,对用户进行身份验证。This scenario uses Azure Active Directory (Azure AD) B2C, a business-to-consumer identity management service, to authenticate users. 在 Azure AD B2C 中,聊天机器人不存储任何敏感的客户帐户信息或凭据。With Azure AD B2C, your chatbot doesn't store any sensitive customer account information or credentials. 有关详细信息,请参阅 Azure AD B2C 概述For more information, see the Azure AD B2C overview.

存储在 Azure SQL 数据库中的信息使用透明数据加密 (TDE) 进行静态加密。Information stored in Azure SQL Database is encrypted at rest with transparent data encryption (TDE). SQL 数据库还提供 Always Encrypted,用于在查询和处理过程中加密数据。SQL Database also offers Always Encrypted which encrypts data during querying and processing. 有关 SQL 数据库安全性的详细信息,请参阅 Azure SQL 数据库安全性和符合性For more information on SQL Database security, see Azure SQL Database security and compliance.

有关设计安全解决方案的一般指南,请参阅 Azure 安全文档For general guidance on designing secure solutions, see the Azure Security Documentation.

复原能力Resiliency

本方案使用 Azure SQL 数据库来存储客户预订项目。This scenario uses Azure SQL Database for storing customer reservations. SQL 数据库包括区域冗余数据库、故障转移组、异地复制和自动备份。SQL Database includes zone redundant databases, failover groups, geo-replication, and automatic backups. 这些功能允许应用程序在发生维护事件或服务中断时继续运行。These features allow your application to continue running if there's a maintenance event or outage. 有关详细信息,请参阅 Azure SQL 数据库可用性功能For more information, see Azure SQL Database availability capabilities.

本方案使用 Application Insights 来监视应用程序的运行状况。To monitor the health of your application, this scenario uses Application Insights. 通过 Application Insights,您可以生成警报并响应可能会影响聊天机器人的客户体验和可用性的性能问题。With Application Insights, you can generate alerts and respond to performance issues that would affect customer experience and availability of the chatbot. 有关详细信息,请参阅 什么是 Application Insights?For more information, see What is Application Insights?

有关其他复原文章,请参阅 设计可靠的 Azure 应用程序For other resiliency articles, see Designing reliable Azure applications.

部署方案Deploy the scenario

必须已经有 Azure 帐户。You must have an existing Azure account. 如果没有 Azure 订阅,请在开始之前创建一个免费帐户If you don't have an Azure subscription, create a free account before you begin.

此方案划分为三个组件,便于浏览:This scenario is divided into three components for easier exploration:

  • 基础结构组件:使用 Azure 资源管理器模板来部署应用服务、Web 应用、Application Insights、存储帐户和 SQL Server 和数据库的核心基础结构组件。Infrastructure components: Use an Azure Resource Manager template to deploy the core infrastructure components of an App Service, Web App, Application Insights, Storage account, and SQL Server and database. 请使用以下步骤:Use the following steps.

    1. 使用以下链接来部署解决方案。Use the link below to deploy the solution.

      将此解决方案部署到 AzureDeploy this solution to Azure

    2. 等待模板部署在 Azure 门户中打开,然后按照 UI 说明创建部署。Wait for the template deployment to open in the Azure portal, and follow the UI instructions to create the deployment. 指定:Specify:

      • 资源组名称,如 myCommerceChatBotInfrastructureA resource group name such as myCommerceChatBotInfrastructure.
      • 选择区域。Select a region.
      • 提供用于 SQL Server 管理员帐户的用户名和安全密码。Provide a username and secure password for the SQL Server administrator account.

      需要几分钟才能完成部署。It takes a few minutes for the deployment to complete.

  • Web 应用聊天机器人:若要使用 Azure CLI 部署机器人服务的机器人,请参阅 部署机器人Web app chatbot: To use Azure CLI to deploy a bot with the Bot Service, see Deploy your bot. 若要将语言理解和智能服务 (LUIS) 添加到机器人,请参阅 使用 Bot FRAMEWORK LUIS CLI 命令部署 LUIS 资源To add Language Understanding and Intelligent Services (LUIS) to the bot, see Deploy LUIS resources using the Bot Framework LUIS CLI commands.

  • 示例 c # 聊天机器人应用程序:使用 Visual Studio 查看 GitHub 上的 示例 c # 应用程序Sample C# chatbot application: Use Visual Studio to review the sample C# application on GitHub. 示例应用程序包括 Azure Active Directory 身份验证组件,并集成了认知服务的语言理解和智能服务 (LUIS) 组件。The sample application includes the Azure Active Directory authentication components and integration with the Language Understanding and Intelligent Services (LUIS) component of Cognitive Services. 此应用程序要求使用 Visual Studio 来生成和部署方案。The application requires Visual Studio to build and deploy the scenario. 有关配置 Azure AD B2C 和 LUIS 应用的其他信息,请参阅 GitHub 存储库文档。Additional information on configuring Azure AD B2C and the LUIS app can be found in the GitHub repo documentation.

定价Pricing

若要了解运行此方案的成本,请使用 Azure 定价计算器To explore the cost of running this scenario, use the Azure pricing calculator. 若要查看不同用例的定价变化情况,请更改服务变量以匹配预期流量。To see how pricing changes for different use cases, change the service variables to match expected traffic. 例如,根据预期聊天机器人处理的消息数,考虑三个成本配置文件:For example, consider three cost profiles based on the number of messages you expect your chatbot to process:

  • 小型,每月处理 < 10000 消息。Small, processing < 10,000 messages per month.
  • 中,每月处理 < 500000 消息。Medium, processing < 500,000 messages per month.
  • 大型,每月处理 < 10000000 消息。Large, processing < 10 million messages per month.

后续步骤Next steps

介绍聊天机器人体系结构的 Azure 体系结构中心文章:Azure Architecture Center articles describing chatbot architectures:

Azure 机器人服务产品文档:Azure Bot Service product documentation:

Microsoft Learn 模块:Microsoft Learn modules: