如何将Botframework网络聊天对话维持一个小时以上?

如何将Botframework网络聊天对话维持一个小时以上?

问题描述:

我浏览了有关botframework-webchat的文档,但找不到关于如何正确处理1个小时以上的对话的任何文档.如果网页在后台长时间闲置,则很可能发生这种情况.

I have looked through the documentation for botframework-webchat and have not been able to find any documentation on how conversations over 1 hour should be handled properly. This situation is most likely to occur if a web page is left idle in the background for an extended period of time.

只要网络聊天在网页上保持活动状态,便会保持直线连接.页面刷新后会发生此问题.

The directline connection is maintained as long as the webchat remains active on a web page. The problem occurs after a page refresh.

最初的短期解决方案是将相关对话信息存储在会话存储中,例如令牌.问题在于,会话的令牌每15分钟刷新一次.必须检索刷新的令牌,以便在刷新页面时保持对话.

The initial short term solution is to store the relevant conversation information in session storage, such as a token. The problem is that the token for the conversation is refreshed every 15 minutes. The refreshed token must be retrieved in order to maintain the conversation upon a page refresh.

我确信存在变通的解决办法,该事件可使用事件回调从Directline客户端对象中检索刷新的令牌.

I am sure a hacky work around exists for retrieving the refreshed token from the directline client object using an event callback.

理想情况下,我正在寻找一种干净的框架设计方法来处理这种情况.

尽管可行的解决方案总比没有解决方案好.

Though a working solution is better than no solution.

相关链接: https://github.com/microsoft/BotFramework-WebChat

谢谢.

该解决方案涉及将会话ID(而不是令牌)存储在会话存储中.页面刷新后,将检索到新令牌.

The solution involved storing the conversation id in session storage instead of the token. Upon a page refresh a new token will be retrieved.

https://github.com/microsoft/BotFramework-WebChat/issues/2899

https://github.com/microsoft/BotFramework-WebChat/issues/2396#issuecomment-530931579

此解决方案有效,但不是最佳解决方案.更好的解决方案是在直接对象中检索活动令牌并将其存储在会话存储中.问题在于,目前还没有一种从直线对象中完全检索刷新令牌的方法.

This solution works but it is not optimal. A better solution would be to retrieve the active token in the directline object and store it in session storage. The problem is that a way to cleanly way to retrieve a refreshed token from a directline object does not exist at this point.