当我从 Microsoft Bot Framework 阅读 Direct Line API 文档时,主机和端口来自哪里

Where is the host and port coming from when I am reading Direct Line API doc from Microsoft Bot Framework

我注意到 Direct Line 请求 url 是这样的:https://localhost:8011/api/ 在文档中。应该用什么代替呢?

我已经从 botbuilder Examples 文件夹中部署了一个 todoBot 示例项目。我在My bots 部分创建了一个机器人,终点是:http://www.bigluntan.com:3978/api/messages。我已经在 Test connection to your bot 部分进行了测试,当我输入内容并发送时它正在工作。现在,我想试试 Direct Line。所以我将 Direct Line 添加到 Channels。但最令人困惑的部分是,我如何称呼这条直线 api,因为终点与我的机器人的终点不同。

我通过反复试验发现了这一点。如果你想使用直线 api 你应该试试 https://directline.botframework.com 作为基数 URL

基数 URL 是 https://directline.botframework.com, so for instance, the POST request to get a new conversationId should be https://directline.botframework.com/api/conversations/

请求 headers 应包括 Content-Type 以及以下内容:

授权:BotConnector <您的秘密>

您的密码是您为注册的机器人创建 Direct Line 频道时创建的代码(见下图)。例如

Content-Type: application/json; charset=utf-8 
Authorization: BotConnector pB7INWcXQjA.cwA.RF4.cglOUNHUOzWVv0Rlk3ovFNhtp1JPz1Zx9jmu8vX7zXs

获得 conversationId 后,您可以 POST 使用 URL https://directline.botframework.com/api/conversations/< conversationId >/messages

发送消息

请求的 body 应包含消息文本。您不会在 POST 回复中收到回复。相反,您需要通过发送 GET 来获取它 https://directline.botframework.com/api/conversations/< conversationId >/messages。从那里,您可以在第一条消息中获取 "from" 值,并在随后对同一对话的调用中使用它(否则机器人将无法识别该状态,只会不断重复第一条回复消息),例如

{
text: "yes",
from: "EQxvIzZOspA"
}