聊天触发器节点#
¥Chat Trigger node
在构建用于聊天机器人和其他聊天界面的 AI 工作流时,使用“聊天触发器”节点。你可以配置用户如何访问聊天,可以使用 n8n 提供的接口之一,也可以使用你自己的接口。你可以添加身份验证。
¥Use the Chat Trigger node when building AI workflows for chatbots and other chat interfaces. You can configure how users access the chat, using one of n8n's provided interfaces, or your own. You can add authentication.
你必须连接一个 Agent 或链 根节点。
¥You must connect either an agent or chain root node.
Workflow execution usage
发送到聊天触发器的每条消息都会执行你的工作流。这意味着,用户发送 10 条消息的一次对话将占用你 10 次执行配额。请查看你的付款计划以了解你的配额详情。
¥Every message to the Chat Trigger executes your workflow. This means that one conversation where a user sends 10 messages uses 10 executions from your execution allowance. Check your payment plan for details of your allowance.
Manual Chat trigger
此节点替换了 1.24.0 版本中的“手动聊天触发”节点。
¥This node replaces the Manual Chat Trigger node from version 1.24.0.
节点参数#
¥Node parameters
公开聊天记录#
¥Make Chat Publicly Available
设置聊天是否应公开(启用)或仅可通过手动聊天界面访问(禁用)。
¥Set whether the chat should be publicly available (turned on) or only available through the manual chat interface (turned off).
构建工作流时,请保持此选项关闭。当你准备好激活工作流并允许用户访问聊天时,请开启此选项。
¥Leave this turned off while you're building the workflow. Turn it on when you're ready to activate the workflow and allow users to access the chat.
模式#
¥Mode
选择用户访问聊天室的方式。从以下选项中选择:
¥Choose how users access the chat. Select from:
- 托管聊天:使用 n8n 的托管聊天界面。推荐大多数用户使用此方法,因为你可以使用 node 选项 配置界面,而无需进行任何其他设置。
¥Hosted Chat: Use n8n's hosted chat interface. Recommended for most users because you can configure the interface using the node options and don't have to do any other setup.
¥Embedded Chat: This option requires you to create your own chat interface. You can use n8n's chat widget or build your own. Your chat interface must call the webhook URL shown in Chat URL in the node.
验证#
¥Authentication
选择是否以及如何限制对聊天的访问。从以下选项中选择:
¥Choose whether and how to restrict access to the chat. Select from:
- 无:聊天未使用身份验证。任何人都可以使用聊天功能。
¥None: The chat doesn't use authentication. Anyone can use the chat.
- 基本身份验证:聊天使用基本身份验证。
¥Basic Auth: The chat uses basic authentication.
-
选择或创建包含用户名和密码的基本身份验证凭据。所有用户必须使用相同的用户名和密码。
¥Select or create a Credential for Basic Auth with a username and password. All users must use the same username and password.
-
n8n 用户身份验证:只有登录到 n8n 账户的用户才能使用聊天功能。
¥n8n User Auth: Only users logged in to an n8n account can use the chat.
初始消息#
¥Initial Message(s)
仅当你使用托管聊天时,此参数才可用。使用它将配置用户访问页面时 n8n 聊天界面显示的消息。
¥This parameter's only available if you're using Hosted Chat. Use it to configure the message the n8n chat interface displays when the user arrives on the page.
节点选项#
¥Node options
可用选项取决于聊天模式。
¥Available options depend on the chat mode.
托管聊天选项#
¥Hosted chat options
允许的来源 (CORS)#
¥Allowed Origin (CORS)
设置可以访问聊天 URL 的来源。输入允许跨域非预检请求的 URL 列表(以逗号分隔)。
¥Set the origins that can access the chat URL. Enter a comma-separated list of URLs allowed for cross-origin non-preflight requests.
使用 *(默认)允许所有来源。
¥Use * (default) to allow all origins.
输入占位符、标题和副标题#
¥Input Placeholder, Title, and Subtitle
输入聊天界面中这些元素的文本。
¥Enter the text for these elements in the chat interface.
加载上一次会话#
¥Load Previous Session
选择是否加载先前聊天会话中的聊天消息。
¥Select whether to load chat messages from a previous chat session.
如果你选择除“关闭”以外的任何选项,则必须将聊天触发器和你正在使用的代理连接到内存子节点。当你将“加载上一个会话”设置为“从内存加载”时,聊天触发器上的内存连接器将显示。n8n 建议将聊天触发器和代理连接到同一个内存子节点,以确保两个节点的数据来源一致。
¥If you select any option other than Off, you must connect the Chat trigger and the Agent you're using to a memory sub-node. The memory connector on the Chat trigger appears when you set Load Previous Session to From Memory. n8n recommends connecting both the Chat trigger and Agent to the same memory sub-node, as this ensures a single source of truth for both nodes.
响应模式#
¥Response Mode
在构建包含处理聊天的代理或链之后步骤的工作流时,请使用此选项。选择以下选项:
¥Use this option when building a workflow with steps after the agent or chain that's handling the chat. Choose from:
- 最后一个节点完成时:聊天触发器节点返回工作流中最后一个执行节点的响应代码和数据输出。
¥When Last Node Finishes: The Chat Trigger node returns the response code and the data output from the last node executed in the workflow.
- 使用响应节点:聊天触发器节点根据 回复聊天 节点或 响应 Webhook 节点中的定义进行响应。在此响应模式下,“聊天触发器”将仅显示这些节点中定义的消息,而不会输出工作流程中最后一个执行的节点的数据。
¥Using Response Nodes: The Chat Trigger node responds as defined in a Respond to Chat node or Respond to Webhook node. In this response mode, the Chat Trigger will solely show messages as defined in these nodes and not output the data from the last node executed in the workflow.
Using Response Nodes
此模式取代了聊天触发器节点 1.2 版本中的 '使用 Webhook 响应节点' 模式。
¥This mode replaces the 'Using Respond to Webhook Node' mode from version 1.2 of the Chat Trigger node.
- 流式响应:启用工作流处理过程中向用户实时传输数据。工作流中需要支持流式的节点(例如,AI 代理 节点)。
¥Streaming response: Enables real-time data streaming back to the user as the workflow processes. Requires nodes with streaming support in the workflow (for example, the AI agent node).
要求点击按钮开始聊天#
¥Require Button Click to Start Chat
设置是否在聊天界面上显示“新建对话”按钮(已开启)或不显示(已关闭)。
¥Set whether to display a New Conversation button on the chat interface (turned on) or not (turned off).
嵌入式聊天选项#
¥Embedded chat options
允许的来源 (CORS)#
¥Allowed Origin (CORS)
设置可以访问聊天 URL 的来源。输入允许跨域非预检请求的 URL 列表(以逗号分隔)。
¥Set the origins that can access the chat URL. Enter a comma-separated list of URLs allowed for cross-origin non-preflight requests.
使用 *(默认)允许所有来源。
¥Use * (default) to allow all origins.
加载上一次会话#
¥Load Previous Session
选择是否加载先前聊天会话中的聊天消息。
¥Select whether to load chat messages from a previous chat session.
如果你选择除“关闭”以外的任何选项,则必须将聊天触发器和你正在使用的代理连接到内存子节点。当你将“加载上一个会话”设置为“从内存加载”时,聊天触发器上的内存连接器将显示。n8n 建议将聊天触发器和代理连接到同一个内存子节点,以确保两个节点的数据来源一致。
¥If you select any option other than Off, you must connect the Chat trigger and the Agent you're using to a memory sub-node. The memory connector on the Chat trigger appears when you set Load Previous Session to From Memory. n8n recommends connecting both the Chat trigger and Agent to the same memory sub-node, as this ensures a single source of truth for both nodes.
响应模式#
¥Response Mode
在构建包含处理聊天的代理或链之后步骤的工作流时,请使用此选项。选择以下选项:
¥Use this option when building a workflow with steps after the agent or chain that's handling the chat. Choose from:
- 最后一个节点完成时:聊天触发器节点返回工作流中最后一个执行节点的响应代码和数据输出。
¥When Last Node Finishes: The Chat Trigger node returns the response code and the data output from the last node executed in the workflow.
- 使用响应节点:聊天触发器节点根据 回复聊天 节点或 响应 Webhook 节点中的定义进行响应。在此响应模式下,“聊天触发器”将仅显示这些节点中定义的消息,而不会输出工作流程中最后一个执行的节点的数据。
¥Using Response Nodes: The Chat Trigger node responds as defined in a Respond to Chat node or Respond to Webhook node. In this response mode, the Chat Trigger will solely show messages as defined in these nodes and not output the data from the last node executed in the workflow.
Using Response Nodes
此模式取代了聊天触发器节点 1.2 版本中的 '使用 Webhook 响应节点' 模式。
¥This mode replaces the 'Using Respond to Webhook Node' mode from version 1.2 of the Chat Trigger node.
- 流式响应:启用工作流处理过程中向用户实时传输数据。需要启用流式支持的节点。
¥Streaming response: Enables real-time data streaming back to the user as the workflow processes. Requires nodes with streaming support enabled.
模板和示例#
¥Templates and examples
相关资源#
¥Related resources
View n8n's Advanced AI documentation.
手动设置聊天回复#
¥Set the chat response manually
如果你不想直接将 Agent 或 Chain 节点的输出发送给用户,则需要手动设置聊天回复。你需要获取代理节点或链节点的输出,并对其进行修改或其他处理,然后再将其发送回用户。
¥You need to manually set the chat response when you don't want to directly send the output of an Agent or Chain node to the user. Instead, you want to take the output of an Agent or Chain node and modify it or do something else with it before sending it back to the user.
在一个基本工作流程中,代理节点和链节点会输出一个名为 output 或 text 的参数,聊天触发器会将此参数的值作为聊天回复发送给用户。
¥In a basic workflow, the Agent and Chain nodes output a parameter named either output or text, and the Chat trigger sends the value of this parameter to the user as the chat response.
如果你需要手动创建发送给用户的响应,则必须创建一个名为 text 或 output 的参数。如果你使用不同的参数名称,聊天触发器将发送整个对象作为响应,而不仅仅是其值。
¥If you need to manually create the response sent to the user, you must create a parameter named either text or output. If you use a different parameter name, the Chat trigger sends the entire object as its response, not just the value.
Respond to Chat node
当你使用 回复聊天 节点手动创建发送给用户的回复时,必须将聊天触发器响应模式设置为 '使用响应节点'。
¥When you are using a Respond to Chat node to manually create the response sent to the user, you must set the Chat Trigger response mode to 'Using Response Nodes'.
常见问题#
¥Common issues
有关常见问题或建议的解决方案,请参阅 常见问题。
¥For common questions or issues and suggested solutions, refer to Common Issues.


