You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Botpress中通过自定义userId恢复历史对话?是否为专业版功能?

关于Botpress自定义userId恢复历史对话的问题

背景

我们在网站中使用Botpress的网站嵌入功能,初始嵌入代码如下:

<script>
  window.botpressWebChat.init({
    host: OWN_URL:BOTPRESS_PORT,
    botId: "test12345"
  })
</script>

Bot可正常显示并交互,但需要实现自定义userId存储并在用户重新登录时恢复历史对话的功能。

尝试操作及遇到的问题

  1. 初始化时配置自定义userId:
<script>
  window.botpressWebChat.init({
    host: OWN_URL:BOTPRESS_PORT,
    botId: "test12345",
    userId: "example12345"
  })
</script>
  1. 从网络面板获取conversationId后,在另一窗口尝试恢复对话:
<script>
  window.botpressWebChat.init({
    host: OWN_URL:BOTPRESS_PORT,
    botId: "test12345",
    userId: "example12345",
    conversationId: ID_RETRIEVED_FROM_NETWORKS_TAB
  })
</script>

此时Botpress返回错误:"The conversation ID doesn't belong to that user",错误逻辑位于channel-web模块的后端api.ts文件中。

  1. 调试后发现,对话记录中的userId与我们设置的自定义值不匹配:
{
  id: 'd3178f66-3b4f-493e-aa39-ce8fcc2195a3',
  clientId: '076ea353-fcd7-4984-869e-713e12b0176f',
  userId: 'a317d806-a6ad-493f-b3b3-70c792f29445',
  createdOn: 2022-07-15T16:39:56.523Z
}

即conversation.userId !== userId,初始化时设置的自定义userId并未同步到对话记录中。

核心疑问

  • 如何在Botpress中通过自定义userId恢复历史对话?
  • 该功能是否属于用户认证相关的专业版功能?我们的需求是让系统现有用户(如example12345)跨设备登录后恢复对话。

内容的提问来源于stack exchange,提问作者Tommy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 19:57:38