MS bot与邮递员在本地测试 [英] MS bot tested locally with postman

查看:71
本文介绍了MS bot与邮递员在本地测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地使用Microsoft Bot Framework,如果我使用MSFT bot模拟器进行测试(在C#.Net Core和Node.js中都可以),则可以很好地工作,但是我不知道如何使用Postman api调用进行测试.

I was playing with Microsoft Bot Framework locally which works fine if I use MSFT bot emulator for testing (both in C# .Net Core and Node.js) but I cannot figure out how to test it using Postman api calls.

我真的需要先在MSFT上注册bot,即使它在本地运行才能获得身份验证吗?

Do I really need to register bot first at MSFT even when it is run locally to be able to get authentication ?

推荐答案

通常,客户端与漫游器之间存在连接器服务.可以绕过连接器服务,然后直接发布到bot,但需要牢记一些注意事项.您将遇到的问题之一是 activity.ServiceUrl 应该是返回消息的回调基本URL:ref MockChannel 来接收这些机器人回复.设置完成后,只需确保发送到bot的消息的ServiceUrl指向该MockChannel.

Normally, there is a Connector Service between the client and a bot. It is possible to bypass the connector services, and post directly to the bot but there are a few things to keep in mind. One of the issues you will run into is the activity.ServiceUrl is expected to be the callback base url for return messages: ref BotFrameworkAdapter#L843 Without a valid ServiceUrl, bot replies will all end in exceptions, since there is no valid place to send the responses. You can setup a MockChannel to receive these bot replies. Once it is setup, just ensure your ServiceUrl of the message sent to the bot is pointing to that MockChannel.

有时,我在PostMan中使用仿真器的连接器服务.这可以在没有 MicrosoftAppId MicrosoftAppPassword 的情况下完成.打开实时聊天"选项卡时,您将在日志中看到仿真器连接器服务正在侦听的终结点:

Sometimes I use the Emulator's Connector Service with PostMan. This can be done without having a MicrosoftAppId and MicrosoftAppPassword. You'll see the endpoint the Emulator Connector Service is listening on within the Log when you open a Live Chat tab:

这将是用于PostMan的基本URL.

This would then be the baseurl to use for PostMan.

创建对话: (注意:仿真器期望带有Bearer令牌的Authorization标头,但该值无关紧要,因为我们没有使用MicrosoftAppId和MicrosoftAppPassword.)

Create Conversation: (note: the emulator expects an Authorization header with a Bearer token, but the value does not matter since we aren't using a MicrosoftAppId and MicrosoftAppPassword)

发布消息:

获取消息:

这篇关于MS bot与邮递员在本地测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆