資訊 Bot 案例Information Bot Scenario

注意

本主題適用於 SDK v3 版本。This topic applies to SDK v3 release. 您可以在這裡找到最新版本 (v4) 的 SDK 文件。You can find the documentation for the latest version of the SDK v4 here.

此資訊 Bot 可透過認知服務 QnA Maker 回答在知識集或常見問題集中定義的問題,也會透過 Azure 搜尋服務回答更開放式的問題。This Information Bot could answer questions defined in a knowledge set or FAQ using Cognitive Services QnA Maker and answer more open-ended questions by using Azure Search.

通常資訊會藏在 SQL Server 等結構化的資料存放區,不過透過搜尋即可輕鬆找到。Often information is buried in structured data stores like SQL Server that can be easily surfaced via search. 想像一下如此方便的情境:使用簡單的交談式命令查閱客戶的訂單狀態。Imagine looking up a customer's order status by simple conversational commands. 使用者使用認知服務 QnA Maker 後,會看到一組有效的搜尋選項,例如查閱客戶、檢閱客戶的最新訂單等。使用者可以利用 QnA 格式定義,輕鬆詢問 Azure 搜尋服務所支援的問題,並在 SQL Database 中查閱儲存的資料。Using Cognitive Services QnA Maker, the user is presented with a set of valid search options like, lookup a customer, review a customer's most recent order, etc. With the QnA format defined the user can easily ask questions that are backed by Azure Search which can look up data stored in a SQL Database.

資訊 Bot 圖表

以下是資訊 Bot 的邏輯流程:Here is the logic flow of an Information bot:

  1. 員工啟動資訊 Bot。The employee starts the Information bot.
  2. Azure Active Directory 驗證該員工的身分。Azure Active Directory validates the employee's identity.
  3. 員工可詢問機器人支援何種查詢。The employee can ask the bot what type of queries are supported.
  4. 認知服務傳回使用 QnA Maker 建置的常見問題集 Bot。Cognitive Services returns a FAQ bot built with the QnA Maker.
  5. 員工定義有效的查詢。The employee defines a valid query.
  6. Bot 將查詢提交至 Azure 搜尋服務,搜尋服務再傳回應用程式資料的相關資訊。The bot submits the query to Azure Search which returns information about the application data.
  7. Application Insights 會收集執行階段遙測,以協助開發 Bot 效能和使用量。Application insights gathers runtime telemetry to help development with bot performance and usage.

範例 BotSample bot

範例 Bot 以 C# 撰寫,在 Microsoft Azure 中執行,並搭配 Azure 搜尋服務從 SQL Database 執行個體索引的資料使用。The sample Bot, written in C#, runs in Microsoft Azure working with data indexed by Azure Search from a SQL Database instance. Bot 會公開一份問題清單,可供詢問如何使用認知服務將問題 (答案) 斷句:QnA Maker。The Bot exposes a list of questions that can be asked with information on how to phrase the question (the answer) using Cognitive Services: QnA Maker. Bot 的使用者可以輸入查詢,以透過 Azure 搜尋服務,在索引資料庫中的廣泛或特定區域中查閱資料。The user of the Bot can then type a query that looks up data via Azure Search in a broad or specific area of the database that is indexed. 此範例提供簡單的資料庫與客戶和訂單資訊。The sample provides a simple database with customers and order information. Application Insights 可追蹤 Bot 的使用方式,並協助您監視例外狀況的 Bot。Application Insights tracks Bot usage and helps you monitor the Bot for exceptions. Bot 發行為 Azure AD 應用程式,讓您可以限制存取資訊的人選。The Bot is published under as an Azure AD app so that you can restrict who has access to the information.

您可以從常見的 Bot Framework 案例範例下載或複製此範例 Bot 的原始程式碼。You can download or clone the source code for this sample bot from Samples for Common Bot Framework Scenarios.

您將使用的元件Components you'll use

資訊 Bot 會使用下列元件:The Information Bot uses the following components:

  • 用以驗證的 Azure ADAzure AD for Authentication
  • 認知服務:QnA MakerCognitive Services: QnA Maker
  • Azure 搜尋服務Azure Search
  • 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. 身為 Bot 開發人員,Azure AD 可讓您專注於建置 Bot,快速而簡單地整合數百萬個全球各地組織所使用的世界級身分識別管理解決方案。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 應用程式,您可以控制哪些人可存取您的 Bot 以及其所公開的資料,而不需要自己實作複雜的驗證和授權系統。By defining an Azure AD app, you can control who has access to your Bot and the data it exposes, without implementing your own complex authentication and authorization system.

認知服務:QnA MakerCognitive Services: QnA Maker

認知服務 QnA Maker 可協助您提供常見問題集的資料來源,讓使用者可以從 Bot 進行查詢。Cognitive Services QnA Maker helps you provide an FAQ data source which your users can query from your Bot. 遇到儲存在不同系統中的大量資訊時,此服務可以有效協助使用者篩選資訊來源和資訊集。When approaching vast amounts of information stored in different systems, it can be useful to help users filter down the information source and set. 單一 SQL 資料庫擁有大量資訊,以至於執行自由格式搜尋時會提供過多資訊。A single SQL database can have enormous amounts of information that when a free form search is applied brings back too much information. 初次使用 QnA Maker 時,您可以為 Bot 使用者定義藍圖,讓使用者了解如何問對問題,以透過 Azure 搜尋服務找到答案。By first using QnA Maker, you can define a road map for your Bot users so they know how to ask intelligent questions that can then be retrieved via Azure Search.

Azure 搜尋服務是應用程式專用的雲端搜尋服務,可讓您快速啟用搜尋索引並執行。Azure Search is a cloud search service for apps that let you get your search indices up and running quickly. 在 Microsoft Azure 上執行,您可以視需求輕鬆增加或減少使用量。Running on top of Microsoft Azure, you can easily scale up and down as your usage demands. 您可以透過對搜尋排名的極佳控制,並找出隱藏在資料庫中的資料,讓搜尋結果促成商業目標。You can connect search results to business goals with great control over search ranking and surface data hidden in your databases.

Application InsightsApplication Insights

Application Insights 可協助您透過應用程式效能管理和立即分析,取得可操作的見解。Application Insights helps you get actionable insights through application performance management (APM) and instant analytics. 根據預設,您可以取得豐富的效能監視、強大的警示與便於取用的儀表板,以協助確保您的 Bot 可供使用,並如預期般執行。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

接下來,請深入了解物聯網 Bot 案例。Next, learn about the Internet of Things bot scenario.