简体   繁体   English

Botframework 聊天在 30 分钟后重新开始

[英]Botframework Chat restarts after 30 minutes

I have a chatbot created using react webchat botframework.我有一个使用 react webchat botframework 创建的聊天机器人。 I understand after an hour the token expires and cannot be refreshed but my issue is that the conversation seems to restart after 30 minutes.我知道一个小时后令牌过期并且无法刷新,但我的问题是对话似乎在 30 分钟后重新开始。

So i refresh the token within 1 hour and get a 200 response that the token is refreshed.所以我在 1 小时内刷新了令牌,并得到一个 200 响应,表明令牌已刷新。 If its within 30 minutes of the conversation original start then I can continue the conversation as expected.如果它在对话原始开始的 30 分钟内,那么我可以按预期继续对话。 If it is over 30 minutes then I will see the conversation history but then it will restart from the beginning and I will see the first message.如果超过 30 分钟,我将看到对话历史记录,但随后它将从头开始,我将看到第一条消息。

Not sure where the issue lies or what information I can provide or how to troubleshoot so please let me know if you have any clue on how to fix this.不确定问题出在哪里或我可以提供什么信息或如何解决问题,所以如果您对如何解决此问题有任何线索,请告诉我。

EDIT: Im wondering if this is possibly related to the userID.编辑:我想知道这是否可能与用户 ID 有关。 If I try to set the userID in the react component I get the message "connectSaga.js:58 Web Chat: user ID is both specified in the Direct Line token and passed in, will use the user ID from the token"如果我尝试在反应组件中设置用户 ID,我会收到消息“connectSaga.js:58 Web 聊天:用户 ID 在 Direct Line 令牌中指定并传入,将使用来自令牌的用户 ID”

How does the user ID get set in the token?如何在令牌中设置用户 ID? How can it be modified?如何修改?

First, regarding the userID, it can be defined in either the request to the DirectLine service that generates the token or in the Web Chat rendering component as a property.首先,关于 userID,它可以在对生成令牌的 DirectLine 服务的请求中定义,也可以在 Web 聊天渲染组件中定义为属性。 As you have seen in the warning, Web Chat defaults to the userID defined with the token request.正如您在警告中看到的,Web 聊天默认为使用令牌请求定义的用户 ID。 It does this for a few reasons, two being security and eliminating two differently defined userIDs from being utilized.这样做有几个原因,两个是安全性,另一个是避免使用两个不同定义的用户 ID。

To 'bake' the userID into the token, it is sent in the request's body, as defined here .要将用户 ID“烘焙”到令牌中,它会在请求正文中发送, 如此处所定义。 Here's an example:这是一个例子:

{
    "user": {
        "id": "dl_abc123",
        "name": "Steve",
        "role": "user"
    }
}

As for the conversation restarting, with Web Chat you don't need to manually refresh the token.至于对话重启,使用 Web Chat 无需手动刷新令牌。 Web Chat takes care of this for you by refreshing it every 15 mins. Web Chat 每 15 分钟刷新一次,为您解决这个问题。 You can see this here in the BotFramework-DirectLineJS repo, which is a dependency of Web Chat.您可以在 BotFramework-DirectLineJS 存储库中看到这一点,它是 Web Chat 的依赖项。 It's possible that your refreshing and Web Chat refreshing is somehow colliding.您的刷新和 Web 聊天刷新可能会发生某种冲突。 Disable/remove your refresh token implementation and try relying on Web Chat alone to take care of is.禁用/删除您的刷新令牌实现并尝试仅依靠 Web 聊天来处理。 See if this makes a difference.看看这是否有所作为。

If it doesn't, then I would suggest you try implementing persistence in your Web Chat hosting page.如果没有,那么我建议您尝试在 Web 聊天托管页面中实现持久性。 This will allow you to reload the page or navigate away and come back without losing the conversation.这将允许您重新加载页面或导航离开并返回而不会丢失对话。 You can follow the instructions in this SO response on how to set this up.您可以按照此 SO 响应中的说明进行设置。

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

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