更改发送到我们的机器人的直接活动的服务网址 [英] Changing the service url for a direct line activity that is sent to our bot

查看:87
本文介绍了更改发送到我们的机器人的直接活动的服务网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用直线api向我们的机器人发送消息,然后不使用直线api从我们的机器人发送消息.为了做到这一点,我们需要一个不同于默认直接api API服务URL的服务URL.

我们尝试在发送直接api的活动中放置不同的服务url,但是当将活动发送到bot时,将填充直接api的服务url.
一旦将活动URL发送到bot,我们也尝试更改其服务url,但是bot仍会尝试将其响应活动发送到直接api.

我们使它起作用的唯一方法是执行以下操作:

We are trying to send a message into our bot using the direct line api and then send a message out from our bot without using the direct line api. In order to do this, we need a different service url than the default direct line api service url.

We have tried putting a different service url in the activity we send the direct line api but then when the activity is sent to the bot the direct line api service url is populated instead.
We have also tried changing the service url in the activity once it has been sent to the bot, but the bot still tries to send its response activity to the direct line api.

The only way we have gotten this to work is to do the following:

((Microsoft.Bot.Connector.IConnectorClient)turnContext.TurnState["Microsoft.Bot.Connector.IConnectorClient"]).BaseUri = new System.Uri("DIFFERENT_SERCVICE_URL");

尽管这可行,但我们认为这不是解决此问题的最佳方法,我们可能不应该修改转弯状态.

Although this works, we don't think it is the best way to solve this problem and we probably should not be modifying the turn state.

是否有更好的方法来更改此服务网址?

Is there a better way to change this service url?

推荐答案

您的机器人至少可以在三个级别上向用户发送活动. TurnContext.SendActivities调用BotAdapter.SendActivitiesAsync,如果使用的是BotFrameworkAdapter,则依次使用存储在依次状态下的连接器客户端调用Conversations.SendToConversationAsync.这三种方法系列都可用于您的机器人,因此,如果要绕过turn上下文,则可以直接使用适配器,而要绕过适配器,则可以直接使用连接器客户端.

There are at least three levels at which your bot can send an activity to the user. TurnContext.SendActivities calls BotAdapter.SendActivitiesAsync, and if you're using a BotFrameworkAdapter then that in turn calls Conversations.SendToConversationAsync using the connector client stored in turn state. All three of these method families are available to your bot, so if you want to bypass the turn context then you can use the adapter directly and if you want to bypass the adapter then you can use the connector client directly.

您发现,当您尝试使用turn上下文发送活动时,您的活动会发送到连接器客户端的基本URI.如果您不想在转弯状态下修改连接器客户端,则可以创建另一个连接器客户端,并使用它.

You've discovered that your activities get sent to the base URI of the connector client when you try to send activities using the turn context. If you don't want to modify the connector client in the turn state then you can create a different connector client and use that instead.

这篇关于更改发送到我们的机器人的直接活动的服务网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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