使用 Gemini 2.5 和 Langfuse 追踪监控 AI 聊天交互
初级
这是一个Building Blocks, AI领域的自动化工作流,包含 5 个节点。主要使用 Code, Agent, ChatTrigger, LmChatGoogleGemini, MemoryBufferWindow 等节点,结合人工智能技术实现智能自动化。 使用 Gemini 2.5 和 Langfuse 追踪监控 AI 聊天交互
前置要求
- •Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "b1926f93e76612afd634dd6dc19dbaa8cf351113b4888b572f3e1d29a5bec617",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "c26d363f-53d2-446b-98db-d68a4b947bc5",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
880,
540
],
"webhookId": "3917af54-131f-41c5-a250-b32e0ff9dc5f",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "01f4841f-2e4d-4beb-8f19-258cb4e8f988",
"name": "gemini-2.5",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
1188,
960
],
"parameters": {
"options": {
"temperature": 0.4
},
"modelName": "models/gemini-2.5-flash-preview-05-20"
},
"credentials": {
"googlePalmApi": {
"id": "XmPj4vZ604DaosrU",
"name": "gemini-personal"
}
},
"typeVersion": 1
},
{
"id": "f63d8101-0b24-4917-9126-ceccc926cb3c",
"name": "内存",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
1396,
760
],
"parameters": {
"contextWindowLength": 100
},
"typeVersion": 1.3
},
{
"id": "c5c637fd-962d-4c2c-bb7a-c35faae85ee1",
"name": "Langfuse LLM",
"type": "@n8n/n8n-nodes-langchain.code",
"position": [
1100,
762.5
],
"parameters": {
"code": {
"supplyData": {
"code": "const { CallbackHandler } = require(\"langfuse-langchain\");\nconst { initChatModel } = require(\"langchain/chat_models/universal\");\n\n// Get connected model\nconst model = await this.getInputConnectionData(\"ai_languageModel\", 0);\nconst modelProvider = model.lc_namespace[2].replace(\"_\", \"-\");\nconst modelName = model.model;\nconst temperature = model.temperature;\n\n// Initialize Langfuse callback handler\nconst sessionId = $input.item.json.sessionId;\nconst langfuseHandler = new CallbackHandler({\n sessionId,\n});\n\nconst llm = await initChatModel(modelName, {\n temperature,\n modelProvider,\n callbacks: [langfuseHandler],\n});\n\nreturn llm;\n"
}
},
"inputs": {
"input": [
{
"type": "ai_languageModel",
"required": true,
"maxConnections": 1
}
]
},
"outputs": {
"output": [
{
"type": "ai_languageModel"
}
]
}
},
"typeVersion": 1
},
{
"id": "c5f53fbe-5603-4384-b4fa-076a69a1f6aa",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1204,
540
],
"parameters": {
"options": {}
},
"typeVersion": 2
}
],
"pinData": {},
"connections": {
"mem": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[]
]
},
"gemini-2.5": {
"ai_languageModel": [
[
{
"node": "Langfuse LLM",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Langfuse LLM": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
初级 - 构建模块, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
自适应RAG
自适应RAG策略:查询分类与检索(Gemini和Qdrant)
Set
Switch
Summarize
+9
39 节点dmr
工程
RAG 2.0 - 答案架构
自适应RAG(Google Gemini和Qdrant):上下文感知查询应答
Set
Switch
Summarize
+9
40 节点Nisa
构建模块
使用LangChain和Gemini构建自定义AI代理(自托管)
使用LangChain和Gemini构建自定义AI代理(自托管)
Code
Chat Trigger
Lm Chat Google Gemini
+2
9 节点shepard
构建模块
🤖 面向您的文档+Google Drive+Gemini+Qdrant的AI驱动RAG聊天机器人
🤖 面向您的文档+Google Drive+Gemini+Qdrant的AI驱动RAG聊天机器人
If
Set
Wait
+21
50 节点Joseph LePage
人工智能
高级AI演示(在AI开发者第14次聚会中展示)
高级AI演示(在AI开发者第14次聚会中展示)
If
Code
Gmail
+19
39 节点Max Tkacz
构建模块
ozki: OpenAI CSV分析
使用OpenAI驱动的数据代理分析Google Sheets数据
Agent
Google Sheets Tool
Chat Trigger
+3
6 节点ozkary
工程
工作流信息
难度等级
初级
节点数量5
分类2
节点类型5
作者
Eduardo Hales
@ehalesFull Stack Developer with 8+ years building web applications, now focused on AI engineering and cybersecurity. I integrate LLMs into production systems, conduct security audits, and help teams build safer, smarter software. Particularly interested in making AI applications both powerful and secure.
外部链接
在 n8n.io 查看 →
分享此工作流