从 iFrame 中的 ChatBot URL 获取动态令牌

Getting dynamic token from ChatBot URL in iFrame

我正在使用 MS BOTFramework 开发 ChatBot。我的 ChatBot 的 URL 是 This 。我在 iFrame 中使用它,如下面的代码 -

{iframe src="https://webchat.botframework.com/embed/testbot?sess=dynamic_value" width = "455" height = "600"}

{/iframe}.

我想在 Bot 代码中获取 sess 的动态值以进行用户身份验证。 这个我试过了 URL

ConnectorClient connector = new ConnectorClient(new System.Uri(message.ServiceUrl));

有什么解决方法吗?

iframed 版本无法做到这一点。您需要在您自己的网站页面上托管网络聊天,然后使用 const params = BotChat.queryParams(location.search); 访问页面上的查询字符串参数。如果您想在机器人中使用查询参数,则需要发送包含参数的反向通道事件并在机器人中处理该事件。

以下是如何发送反向通道事件的示例:https://github.com/Microsoft/BotFramework-WebChat/blob/master/samples/backchannel/index.html