简体   繁体   English

在 Bot Framework 上创建直线通道并使用 Postman 进行测试

[英]Direct Line Channel Creation on Bot Framework and test with Postman

I have been testing some botbuilder samples in python with Bot Framework Emulator , both on localhost.我一直在使用Bot Framework Emulator在 python 中测试一些botbuilder 示例,都在本地主机上。 But in order to understand how the communication was happening, I decided to make the requests via Postman through Direct Line 3.0 .但为了了解通信是如何发生的,我决定通过Direct Line 3.0通过Postman提出请求。 Despite being able to create a conversation, send messages and receive the activities of a conversation, I cannot create the Direct Line Channel via Postman for my bot, only through the Bot Framework Emulator.尽管能够创建对话、发送消息和接收对话活动,但我无法通过 Postman 为我的机器人创建 Direct Line Channel,只能通过 Bot Framework Emulator。

To do the test I do the following steps:要进行测试,我执行以下步骤:

  1. I run any python Bot Framework Samples on my computer on port 3978我在我的计算机上的端口 3978 上运行任何 python Bot Framework 示例

Bot running on 3978机器人在 3978 上运行

  1. I open a conversation in Bot Framework Emulator through port 3978. (At this point, the emulator tells me that it opened a service on port 49780.)我通过端口 3978 在 Bot Framework Emulator 中打开了一个对话。(此时,模拟器告诉我它在端口 49780 上打开了一个服务。)

Emulator listening on http://[::]:49780模拟器监听 http://[::]:49780

  1. I make a Direct Line request on port 49780 through Postman to create a conversation.我通过 Postman 在端口 49780 上发出 Direct Line 请求以创建对话。

I would like to do step 2 without using the Bot Framework Emulator, either through the REST API or through the Python code.我想通过 REST API 或 Python 代码在不使用 Bot Framework Emulator 的情况下执行第 2 步。

Step 2 is not really about creating a conversation.第 2 步并不是真正的创建对话。 It's more to do with the Emulator creating a tunnel to emulate the connection between the bot and the Azure Bot Service.它更多地与模拟器创建隧道来模拟机器人和 Azure 机器人服务之间的连接有关。 This is not something you would control in a live deployment scenario.这不是您在实时部署方案中可以控制的事情。 In a proper deployment, the Azure Bot Service will automatically handle routing messages from various channels to the bot's messaging endpoint.在适当的部署中,Azure 机器人服务将自动处理从各种渠道到机器人的消息传递终结点的路由消息。 All you would need to do is communicate with the bot over Direct Line as normal.您需要做的就是像往常一样通过 Direct Line 与机器人通信。

Since Direct Line requires the Azure Bot resource to function (which the Emulator well, emulates) the only way to test it without the Emulator would be to create an Azure Bot resource, create a secure tunnel with something like ngrok, and set the ngrok URL as your messaging endpoint in Azure.由于 Direct Line 需要 Azure Bot 资源才能运行(模拟器可以很好地模拟),所以在没有模拟器的情况下测试它的唯一方法是创建一个 Azure Bot 资源,使用 ngrok 之类的东西创建一个安全隧道,然后设置 ngrok URL作为 Azure 中的消息传递端点。 At that point, Direct Line messages should reach your bot.此时,Direct Line 消息应该会到达您的机器人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM