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

Direct Line API 3.0 中的重要概念Key concepts in Direct Line API 3.0

可使用 Direct Line API 在机器人和自己的客户端应用程序之间实现通信。You can enable communication between your bot and your own client application by using the Direct Line API. 本文介绍 Direct Line API 3.0 中的重要概念,同时介绍了相关的开发人员资源。This article introduces key concepts in Direct Line API 3.0 and provides information about relevant developer resources. 可以使用 SDK、REST API 或 Web Chat 来构建客户端。You can build a client using the SDK, REST API, or Web Chat.

身份验证Authentication

可通过以下方式对 Direct Line API 3.0 请求进行身份验证:使用从 Azure 门户的 Direct Line 通道配置页中获取的机密,或使用在运行时获得的令牌 。Direct Line API 3.0 requests can be authenticated either by using a secret that you obtain from the Direct Line channel configuration page in the Azure Portal or by using a token that you obtain at runtime. 有关详细信息,请参阅身份验证For more information, see Authentication.

开始聊天Starting a conversation

Direct Line 会话由客户端显式打开,只要机器人和客户端参与并拥有有效凭据,就可以运行。Direct Line conversations are explicitly opened by clients and may run as long as the bot and client participate and have valid credentials. 有关详细信息,请参阅开始聊天For more information, see Start a conversation.

发送消息Sending messages

使用 Direct Line API 3.0,客户端可通过发出 HTTP POST 请求向机器人发送消息。Using Direct Line API 3.0, a client can send messages to your bot by issuing HTTP POST requests. 客户端可为每个请求发送一条消息。A client may send a single message per request. 有关详细信息,请参阅向机器人发送活动For more information, see Send an activity to the bot.

接收消息Receiving messages

使用 Direct Line API 3.0,客户端可通过 WebSocket 流或通过发出 HTTP GET 请求来接收机器人发出的消息。Using Direct Line API 3.0, a client can receive messages from your bot either via WebSocket stream or by issuing HTTP GET requests. 使用其中任一技术,客户端都可一次接收多条来自机器人的消息,作为 ActivitySet 的一部分。Using either of these techniques, a client may receive multiple messages from the bot at a time as part of an ActivitySet. 有关详细信息,请参阅从机器人接收活动For more information, see Receive activities from the bot.

开发人员资源Developer resources

客户端库Client libraries

Bot Framework 提供了客户端库,帮助用户通过 C# 和 Node.js 访问 Direct Line API 3.0。The Bot Framework provides client libraries that facilitate access to Direct Line API 3.0 via C# and Node.js.

  • 要在 Visual Studio 项目中使用 .NET 客户端库,请安装 Microsoft.Bot.Connector.DirectLineNuGet 包To use the .NET client library within a Visual Studio project, install the Microsoft.Bot.Connector.DirectLine NuGet package.

  • 要使用 Node.js 客户端库,请使用 NPM 安装 botframework-directlinejs 库(或下载源)。To use the Node.js client library, install the botframework-directlinejs library using NPM (or download the source).

网上聊天控件Web chat control

Bot Framework 提供了一个控件,用于将 Direct-Line 驱动的机器人嵌入到客户端应用程序中。The Bot Framework provides a control that enables you to embed a Direct-Line-powered bot into your client application. 有关详细信息,请参阅 Microsoft Bot Framework 网上聊天控件For more information, see the Microsoft Bot Framework WebChat control.