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

商业机器人方案Commerce bot scenario


本主题适用于 SDK v3 版本。This topic applies to SDK v3 release. 可以在此处找到最新版 SDK (v4) 的文档。You can find the documentation for the latest version of the SDK v4 here.

商业机器人方案描述的机器人使用酒店的礼宾服务代替人们通常进行的传统电子邮件和电话交互。The Commerce bot scenario describes a bot that replaces the traditional e-mail and phone call interactions that people typically have with a hotel's concierge service. 机器人利用认知服务通过文本和语音更好地处理客户请求,并通过与后端服务集成收集上下文。The bot takes advantage of Cognitive Services to better process customer requests via text and voice with context gathered from integration with backend services.


以下是充当酒店礼宾员的商业机器人的逻辑流程:Here is the logic flow of a Commerce bot that functions as a concierge for a hotel:

  1. 客户使用酒店移动应用。The customer uses the hotel mobile app.
  2. 用户使用 Azure AD B2C 进行身份验证。Using Azure AD B2C, the user authenticates.
  3. 用户使用自定义应用程序机器人请求信息。Using the custom Application Bot, user requests information.
  4. 认知服务帮助处理自然语言请求。Cognitive Services helps process the natural language request.
  5. 响应由可使用自然聊天精简问题的客户进行审阅。Response is reviewed by customer who can refine the question using natural conversation.
  6. 用户对结果感到满意之后,应用程序机器人将更新客户的预订。After the user is happy with the results, the Application Bot updates the customer’s reservation.
  7. Application Insights 收集运行时遥测来帮助提高机器人性能和使用率。Application insights gathers runtime telemetery to help development with bot performance and usage.

示例机器人Sample bot

示例商业机器人是围绕虚构的酒店礼宾服务进行设计的。The sample Commerce bot is designed around a fictitious hotel concierge service. 用 C# 编写的客户使用连锁店的会员服务移动应用通过酒店向 Azure AD B2C 进行身份验证后,即可访问机器人。Written in C#, customers access the Bot once they've authenticated Azure AD B2C with a hotel via the chain's member services mobile app. 连锁店在 SQL 数据库中存储预订。The chain stores reservations in a SQL Database. 客户可以使用自然短语问题,例如“在我住宿期间租用泳池小屋要多少钱”。A customer can use natural phrase questions like "How much to rent a pool cabana for my stay". 而机器人则获得有关客人住宿的酒店和住宿持续时间的上下文。The Bot in turn has context about what hotel and the duration of the guest's stay. 此外,语言理解 (LUIS) 服务使机器人可以轻松地从一个简单的短语(如“泳池小屋”)获取上下文。In addition, Language Understanding (LUIS) Service makes it easy for the bot to get context from even a simple phrase like "pool cabana". 机器人提供解答,然后可以为客人预订小屋,并提供有关天数和小屋类型的选项。The Bot provides the answer and then can offer to book a cabana for the guest, providing choices around the number of days and type of cabana. 一旦机器人拥有所有必要的数据,它就会预订请求。Once the Bot has all the necessary data, it books the request. 客人也可以使用他们的声音发出相同的请求。The guest can also use their voice to make the same request.

可以从常见 Bot Framework 方案的示例下载或克隆此示例机器人的源代码。You can download or clone the source code for this sample bot from Samples for Common Bot Framework Scenarios.

将使用的组件Components you'll use

商业机器人使用以下组件:The Commerce bot uses the following components:

  • 用于身份验证的 Azure ADAzure AD for Authentication
  • 认知服务:LUISCognitive Services: LUIS
  • Application InsightsApplication Insights

Azure Active Directory (Azure AD)Azure Active Directory (Azure AD)

Azure Active Directory (Azure AD) 是 Microsoft 提供的基于多租户云的目录和标识管理服务。Azure Active Directory (Azure AD) is Microsoft’s multi-tenant cloud based directory and identity management service. 作为机器人开发工具,Azure AD 让你可以快速轻松地与世界各地数百万组织使用的世界一流标识管理解决方案集成,从而专注于构建机器人。As a Bot developer, Azure AD lets you focus on building your Bot by making it fast and simple to integrate with a world class identity management solution used by millions of organizations around the world. Azure AD 支持使用 B2C 连接器,目的是确定使用外部 ID(例如 Google、Facebook 或 Microsoft 帐户)的用户。Azure AD supports a B2C connector allowing you to identify individuals using external IDs such as Google, Facebook, or a Microsoft Account. Azure AD 消除了你必须管理用户凭据的责任,而让你专注于机器人解决方案,因为知道你可以将机器人的用户与应用程序公开的正确数据相关联。Azure AD removes the responsibility from you having to manage the user's credentials and instead focus your Bot's solution knowing you can correlate the user of the Bot with the correct data exposed by your application.

认知服务:LUISCognitive Services: LUIS

作为认知服务技术系列的成员,语言理解 (LUIS) 为你的应用带来了机器学习的强大功能。As a member of the Cognitive Services family of technologies, Language Understanding (LUIS) brings the power of machine learning to your apps. 目前,LUIS 支持多种语言,使机器人能够理解人们想要的内容。Currently, LUIS supports several languages that enables your Bot to understand what a person wants. 与 LUIS 集成时,你表达意向并定义机器人理解的实体。When integrating with LUIS, you express intent and define the entities your Bot understands. 然后,通过使用示例话语训练机器人,教机器人理解这些意向和实体。You then teach your Bot to understand those intents and entities by training it with example utterances. 你可以使用短语列表和正则表达式功能调整集成,以便机器人尽可能流利,满足你的特定聊天需求。You have the ability to tweak your integration using phrase lists and regex features so that your Bot is as fluid as possible for your particular conversation needs.

Application InsightsApplication Insights

Application Insights 可帮助你通过应用程序性能管理 (APM) 和即时分析获取可付诸实施的见解。Application Insights helps you get actionable insights through application performance management (APM) and instant analytics. 开箱即可获得丰富的性能监视、功能强大的警报和易于使用的仪表板,帮助确保机器人可用且行为符合预期。Out of the box you get rich performance monitoring, powerful alerting, and easy-to-consume dashboards to help ensure your Bot is available and performing as you expect. 可以快速了解是否有问题,然后执行根本原因分析以便查找并解决问题。You can quickly see if you have a problem, then perform a root cause analysis to find and fix the issue.

后续步骤Next steps

接下来,了解 Cortana 技能机器人方案。Next, learn about the Cortana Skill bot scenario.