Skip to content

聊天触发器节点常见问题(Chat Trigger node common issues)#

这里是一些关于 聊天触发节点 的常见错误和问题,以及解决或排查它们的步骤。

🌐 Here are some common errors and issues with the Chat Trigger node and steps to resolve or troubleshoot them.

将数据从网站传递到嵌入式聊天触发节点(Pass data from a website to an embedded Chat Trigger node)#

在网站中嵌入聊天触发节点时,你可能想向聊天触发器传递额外的信息。例如,传递存储在网站 cookie 中的用户 ID。

🌐 When embedding the Chat Trigger node in a website, you might want to pass extra information to the Chat Trigger. For example, passing a user ID stored in a site cookie.

要做到这一点,请在嵌入式聊天窗口中传递给 createChat 函数的 JSON 对象中使用 metadata 字段:

🌐 To do this, use the metadata field in the JSON object you pass to the createChat function in your embedded chat window:

1
2
3
4
5
6
createChat({
	webhookUrl: 'YOUR_PRODUCTION_WEBHOOK_URL',
	metadata: {
		'YOUR_KEY': 'YOUR_DATA'
	};
});

metadata 字段可以包含任意数据,这些数据将与其他输出数据一起出现在聊天触发器输出中。从那里,你可以像往常一样使用 n8n 的 数据处理功能 查询和处理下游节点中的数据。

🌐 The metadata field can contain arbitrary data that will appear in the Chat Trigger output alongside other output data. From there, you can query and process the data from downstream nodes as usual using n8n's data processing features.

聊天触发器节点无法获取历史消息(Chat Trigger node doesn't fetch previous messages)#

当你配置聊天触发器节点时,如果不小心配置会话加载,可能会在获取以前的消息时遇到问题。这通常会表现为 workflow could not be started! 错误。

🌐 When you configure a Chat Trigger node, you might experience problems fetching previous messages if you aren't careful about how you configure session loading. This often manifests as a workflow could not be started! error.

在聊天触发器中,加载上一个会话选项使用 sessionID 检索会话的先前聊天消息。当你将加载上一个会话选项设置为从内存时,通常最好将 相同的内存节点 连接到工作流中的聊天触发器和代理:

🌐 In Chat Triggers, the Load Previous Session option retrieves previous chat messages for a session using the sessionID. When you set the Load Previous Session option to From memory, it's almost always best to connect the same memory node to both the Chat Trigger and the Agent in your workflow:

  1. 在你的聊天触发器节点中,将加载之前的会话选项设置为从记忆中。只有在你将聊天公开时才会显示此选项。
  2. 将一个 简单记忆 节点连接到 记忆 接口。
  3. 将相同的 Simple Memory 节点连接到你的 AgentMemory 接口。
  4. 简单记忆 节点中,将 会话 ID 设置为 已连接的聊天触发节点

一种可能需要将独立的内存节点附加到你的聊天触发器和代理的情况是,如果你希望在内存节点中将会话ID设置为以下定义

🌐 One instance where you may want to attach separate memory nodes to your Chat Trigger and the Agent is if you want to set the Session ID in your memory node to Define below.

如果你是从一个表达式中获取会话 ID,则相同的表达式必须适用于附加到它的每个节点。如果该表达式与每个需要内存的节点不兼容,你可能需要使用单独的内存节点,以便可以为每个节点单独自定义会话 ID 的表达式。

🌐 If you're retrieving the session ID from an expression, the same expression must work for each of the nodes attached to it. If the expression isn't compatible with each of the nodes that need memory, you might need to use separate memory nodes so you can customize the expression for the session ID on a per-node basis.