關於 Azure Bot ServiceAbout Azure Bot Service

適用於: 是 SDK v4 是 SDK v3 APPLIES TO: yesSDK v4 yesSDK v3

Azure Bot 服務和 Bot Framework 提供可在單一位置建立、測試、部署及管理智慧型 Bot 的工具。Azure Bot Service and Bot Framework provide tools to build, test, deploy, and manage intelligent bots all in one place. 利用 SDK 提供的模組化可延伸架構,工具、範本和 AI 服務開發人員可以建立可使用語音、理解自然語言、處理問與答等功能的 Bot。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.

什麼是 Bot?What is a bot?

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. 在不再需要直接人為介入的自動化系統上,Bot 可用於輪替簡單、重複性工作,例如預訂晚餐或蒐集設定檔資訊。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. 使用者可使用文字、互動式卡片和語音來與 Bot 交談。Users converse with a bot using text, interactive cards, and speech. Bot 互動可以是快速的問與答,也可以是以智慧方式提供服務存取權的複雜對話。A bot interaction can be a quick question and answer, or it can be a sophisticated conversation that intelligently provides access to services.

Bot 很類似現代化 Web 應用程式,在網際網路上運作,並使用 API 來傳送和接收訊息。Bots are a lot like modern web applications, living on the internet and use APIs to send and receive messages. 視 Bot 的種類而定,Bot 的功能差異很大。What's in a bot varies widely depending on what kind of bot it is. 現代化 Bot 軟體依賴一些技術和工具,可在各種平台上提供日益複雜的體驗。Modern bot software relies on a stack of technology and tools to deliver increasingly complex experiences on a wide variety of platforms. 不過,簡單的 Bot 可能只會收到訊息,並以極少的相關程式碼來回應使用者。However, a simple bot could just receive a message and echo it back to the user with very little code involved.

Bot 可執行其他類型的軟體可以執行的作業:讀取和寫入檔案、使用資料庫和 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. Bot 的特點就是其使用通常保留給人與人通訊的機制。What makes bots unique is their use of mechanisms generally reserved for human-to-human communication.

Azure Bot 服務和 Bot Framework 可提供:Azure Bot Service and Bot Framework offer:

  • 可供開發 Bot 的 Bot Framework SDKBot Framework SDK for developing bots
  • Bot Framework 工具,可涵蓋端對端 Bot 開發工作流程Bot Framework Tools to cover end-to-end bot development workflow
  • Bot Framework Service (BFS),可在 Bot 與通道之間傳送及接收訊息和事件Bot Framework Service (BFS) to send and receive messages and events between bots and channels
  • Azure 中的 Bot 部署和通道組態Bot deployment and channel configuration in Azure

此外,Bot 可使用其他 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

建立 BotBuilding a bot

Azure Bot 服務和 Bot Framework 可提供一組整合式工具與服務,可加快此程序。Azure Bot Service and Bot Framework offer an integrated set of tools and services to facilitate this process. 選擇您慣用的開發環境或命令列工具來建立 Bot。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 正在開發中。)我們在 Bot 各種開發階段皆提供各項工具,協助您設計及建置 Bot。(SDKs for Java and Python are under development.) We provide tools for various stages of bot development to help you design and build bots.

Bot 概觀


如同任何類型的軟體,務必徹底了解目標、程序及使用者需求,才能建立成功的 Bot。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. 撰寫程式碼之前,請先參閱 Bot 設計指南 了解最佳作法,並找出您的 Bot 需求。Before writing code, review the bot design guidelines for best practices and identify the needs for your bot. 您可以建立簡單的 Bot 或納入更複雜的功能,例如語音、自然語言理解或問題解答。You can create a simple bot or include more sophisticated capabilities such as speech, natural language understanding,and question answering.


Bot 是一項 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 Service 和 Bot Framework 的其中一個元件。Bot Framework Service is one of the components of the Azure Bot Service and Bot Framework. 您可以使用任意多個環境和語言建立 Bot。You can create bots in any number of environments and languages. 您可以在 Azure 入口網站中開始進行 Bot 開發,或使用 [C# | JavaScript] 範本進行本機開發。You can start your bot development in the Azure portal, or use [C# | JavaScript] templates for local development.

我們在 Azure Bot Service 和 Bot Framework 中提供可用來增強 Bot 功能的其他元件As part of the Azure Bot Service and Bot Framework, we offer additional components you can use to extend your bot's functionality

功能Feature 說明Description 連結Link
新增自然語言處理Add natural language processing 讓您的 Bot 能夠理解自然語言、理解拼字錯誤、使用語音,以及辨識使用者的意圖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 和 nA Maker),可在 Bot 對話期間,採用智慧方式判斷各個模型的使用時機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 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. 請參閱左側文章了解更多 Bot 功能,第一篇為傳送訊息Explore the articles on the left, starting with sending messages, for more bot functionality.

此外,我們會提供命令列工具,協助您建立、管理及測試 Bot 資產。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.


Bot 是將許多不同組件整合在一起運作的複雜應用程式。Bots are complex apps, with a lot of different parts working together. 和其他複雜的應用程式一樣,這種方式會導致一些有趣的錯誤,或是讓 Bot 產生出乎意料的行為。Like any other complex app, this can lead to some interesting bugs or cause your bot to behave differently than expected. 在發佈之前,請先測試 Bot。Before publishing, test your bot. 在發行 Bot 以供使用前,我們會提供數種方式來測試 Bot:We provide several ways to test bots before they are released for use:

  • 使用模擬器在本機測試 Bot。Test your bot locally with the emulator. Bot Framework 模擬器是獨立的應用程式,不僅提供交談介面,還提供偵錯和訊問工具來協助您了解 Bot 的運作方式和原因。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. 模擬器可以隨著開發中的 Bot 應用程式在本機執行。The emulator can be run locally alongside your in-development bot application.

  • Web 上測試您的 Bot。Test your bot on the web. 透過 Azure 入口網站進行設定後,Bot 也可透過網路聊天介面觸達。Once configured through the Azure portal your bot can also be reached through a web chat interface. 網路聊天介面適合用來將 Bot 的存取權授與給測試人員,以及其他無法直接存取 Bot 執行中程式碼的人員。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 月更新單元測試您的 Bot。Unit Test your bot with the July update of Bot Framework SDK.


當您準備在 Web 上提供您的 Bot 時,請將 Bot 發佈至 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. 在公用網際網路上有一個位址是 Bot 在您的網站上,或在聊天通道內活化的第一個步驟。Having an address on the public internet is the first step to your bot coming to life on your site, or inside chat channels.


將您的 Bot 連接到 Facebook、Messenger、Kik、Skype、Slack、Microsoft Teams、Telegram、簡訊 /SMS、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 應用程式都會接收統一、正規化的訊息串流。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.


使用在 Azure 入口網站收集的資料,就有機會改善 Bot 功能和效能。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

請查看這些 Bot 個案研究,或按一下下方連結,即可建立 Bot。Check out these case studies of bots or click on the link below to create a bot.