不说废话:
json{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-140,
-180
],
"id": "2d020c78-698f-4ca9-b4aa-dc6e3bdd92e7",
"name": "When clicking ‘Execute workflow’",
"disabled": true
},
{
"parameters": {
"promptType": "define",
"text": "=---\n# 微信聊天分析助手 (由 ChatLog SSE 提供支持)\n\n你是“微信聊天分析助手”,一个通过 `chatlog` SSE 服务与微信数据交互的智能助理。你的核心职责是理解用户意图,选择并调用正确的工具查询数据,并对查询结果进行智能分析和结构化呈现。\n\n## 核心指令\n你的行为由以下核心指令驱动,这是你决策的最高优先级规则:\n`{{ \"Choose proper tool for user input:\"+ JSON.stringify($json) }}`\n\n## 可用工具 (由 ChatLog SSE 提供)\n你必须通过一个通用的 `toolsCall` 方法来调用以下工具,并提供正确的工具名称和参数。\n\n1. **`query_chat_room`**: 查询群聊列表。\n * **何时使用**: 当用户想要查找某个群聊,但不确定其准确名称时。\n * **参数**: `keyword` (string, 可选), `limit` (number, 可选), `offset` (number, 可选)。\n * **返回**: 群聊列表。\n\n2. **`chatlog`**: 查询聊天记录。\n * **何时使用**: 当需要获取具体某个人或群的聊天内容时。**必须**先知道准确的`talker` ID。\n * **参数**: `talker` (string, 必填), `keyword` (string, 可选), `sender` (string, 可选), `time` (string, 可选), `limit` (number, 可选)。\n * **返回**: 原始聊天记录文本。\n\n3. **`query_contact`**: 查询联系人(好友)。\n * **何时使用**: 当用户想要查找某个联系人信息时。\n * **参数**: `keyword` (string, 可选), `limit`, `offset`。\n\n4. **`query_recent_chat`**: 查询最近会话。\n * **何时使用**: 当用户想了解最近和谁聊过天时。\n * **参数**: `keyword` (string, 可选), `limit`, `offset`。\n\n5. **`current_time`**: 获取当前服务器时间。\n * **何时使用**: 当需要确认当前日期或时间以辅助其他查询时。\n\n## 执行策略:群聊记录查询标准工作流\n当用户意图是查询**群聊记录**时,你必须严格遵循以下工作流:\n\n1. **解析意图**: 从用户输入中提取群聊的**关键词**和聊天记录的**关键词**。\n2. **步骤一:查询群聊ID**: **必须**首先调用 `query_chat_room` 工具,使用群聊关键词进行搜索。\n3. **步骤二:选择目标群聊**:\n * 从 `query_chat_room` 的返回结果中,**默认选择列表中的第一个群聊**作为目标。\n * 获取该群聊的 `Name` 属性,这就是下一步需要的 `talker` ID。\n * 如果未找到群聊,应礼貌地告知用户并中止流程。\n4. **步骤三:查询聊天记录**: **必须**调用 `chatlog` 工具,并将上一步获取的群聊 `Name` 作为 `talker` 参数传入,同时传入聊天记录的关键词、时间等其他参数。\n5. **步骤四:分析与呈现**: **禁止**直接输出原始记录。**必须**根据下方的“结果呈现与智能分析”部分的指导,对获取的聊天记录进行处理,并生成结构化的分析报告。\n\n## 结果呈现与智能分析\n当你从 `chatlog` 工具获取到聊天记录后,你必须对内容进行分析和结构化处理。你的最终输出应遵循以下格式:\n\n### 📈 [群聊名称] - 聊天记录分析\n\n**核心主题:**\n- [从对话中提炼出的主要议题或讨论焦点,例如:关于新版本部署方案的讨论]\n- [另一个主要议题,例如:用户反馈的Bug分析与跟进]\n\n**关键信息摘要:**\n- **[决策]**: [记录讨论中形成的重要决定,例如:确定本周五进行V2.1版本上线]\n- **[问题]**: [记录提出的、需要后续跟进的关键问题,例如:@张三 需要确认新服务器的配置]\n- **[要点]**: [记录其他重要的信息点或结论]\n\n**提及的工具与链接:**\n- [列出对话中提到的具体工具、软件、技术栈等,例如:Jira, Figma]\n- [列出分享的URL链接,例如:https://example.com/design-spec]\n\n---\n*原始记录已获取,以上为智能分析摘要。*\n\n\n## 示例工作流\n\n**用户输入**: \"帮我看看昨天 AI项目群 里大家有讨论到‘部署’相关的内容吗?\"\n\n1. **解析**: 识别群聊关键词 \"AI项目群\",记录关键词 \"部署\",时间 \"昨天\"。\n2. **步骤 1 (查群聊)**: `调用 toolsCall(name=\"query_chat_room\", arguments={\"keyword\": \"AI项目群\"})`。\n3. **工具返回**: `[{Name: \"AI项目群-V3-dev\", ...}]`。\n4. **步骤 2 (选群聊)**: 确定 `talker` ID 为 `\"AI项目群-V3-dev\"`。\n5. **步骤 3 (查记录)**: `调用 toolsCall(name=\"chatlog\", arguments={\"talker\": \"AI项目群-V3-dev\", \"keyword\": \"部署\", \"time\": \"昨天\"})`。\n6. **步骤 4 (分析与呈现)**: 对返回的聊天记录进行分析,并按照“结果呈现与智能分析”的格式输出报告。\n\n## 错误处理\n- **未找到群聊**: 如果 `query_chat_room` 返回空,回复:\"抱歉,未能找到相关的群聊,请您尝试提供更具体的群聊名称。\"\n- **未找到记录**: 如果 `chatlog` 返回空,回复:\"已在群聊 \"[群聊名称]\" 中为您查询,但未找到与\"[关键词]\"相关的聊天记录。\"\n",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2,
"position": [
780,
340
],
"id": "c7d6279b-a5ad-432a-9304-1b87fddf77ca",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "deepseek/deepseek-chat-v3-0324:free",
"mode": "list",
"cachedResultName": "deepseek/deepseek-chat-v3-0324:free"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
140,
540
],
"id": "e9154cee-5078-4c13-83d5-ace9429be696",
"name": "deep-seek",
"credentials": {
"openAiApi": {
"id": "7zzh8qcPX947r7su",
"name": "OpenAi account"
}
},
"disabled": true
},
{
"parameters": {
"method": "POST",
"url": "https://open.feishu.cn/open-apis/bot/v2/hook/ec0a3959-81ce-4ad6-b97a-95a0abc1e9bf",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"msg_type\": \"interactive\",\n \"card\": {\n \"schema\": \"2.0\",\n \"config\": {\n \"update_multi\": true,\n \"style\": {\n \"text_size\": {\n \"normal_v2\": {\n \"default\": \"normal\",\n \"pc\": \"normal\",\n \"mobile\": \"heading\"\n }\n }\n }\n },\n \"body\": {\n \"direction\": \"vertical\",\n \"padding\": \"12px 12px 12px 12px\",\n \"elements\": [\n {\n \"tag\": \"markdown\",\n \"content\": \"{{ $json.output ? JSON.stringify($json.output).slice(1, -1) : '' }}\",\n \"text_align\": \"left\",\n \"text_size\": \"normal_v2\",\n \"margin\": \"0px 0px 0px 0px\"\n }\n ]\n },\n \"header\": {\n \"title\": {\n \"tag\": \"plain_text\",\n \"content\": \"AI News\"\n },\n \"subtitle\": {\n \"tag\": \"plain_text\",\n \"content\": \"\"\n },\n \"template\": \"blue\",\n \"padding\": \"12px 12px 12px 12px\"\n }\n }\n}\n",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1700,
-60
],
"id": "9f420c23-2911-45d4-95b4-51ec93a1368e",
"name": "HTTP Request1"
},
{
"parameters": {
"url": "http://host.docker.internal:5030/api/v1/chatroom?format=json",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "format",
"value": "text"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
100,
-180
],
"id": "6efc2ae8-ca7b-438e-9687-0ada9a50a10c",
"name": "获取群聊列表",
"disabled": true
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
620,
-100
],
"id": "509463da-61ea-42b0-87b3-bda58d895d83",
"name": "Loop Over Items",
"disabled": true
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
0,
220
],
"id": "c0adb828-daca-4b58-9704-9cd163754f5b",
"name": "When chat message received",
"webhookId": "ff87f1f7-bd82-4384-9d94-53611e21f058",
"disabled": true
},
{
"parameters": {},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
800,
620
],
"id": "ad9a93dc-ba47-49a2-afc1-902b1e28eba1",
"name": "Simple Memory",
"disabled": true
},
{
"parameters": {
"sseEndpoint": "http://host.docker.internal:5030/sse"
},
"type": "@n8n/n8n-nodes-langchain.mcpClientTool",
"typeVersion": 1,
"position": [
1060,
620
],
"id": "b153ce29-31b8-408e-b8ae-1aac16935734",
"name": "chatlog"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
"typeVersion": 1,
"position": [
460,
680
],
"id": "2b72d692-58e7-4ed0-b66e-c69d5dea0cd6",
"name": "DeepSeek Chat Model",
"credentials": {
"deepSeekApi": {
"id": "NpOVqRffxIaXSnPU",
"name": "DeepSeek account"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 9
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
80,
420
],
"id": "e8d5b9c2-3de9-40b2-9ea6-c2fe27f50346",
"name": "Schedule Trigger"
},
{
"parameters": {
"jsCode": "\n\nreturn {\n 'input':'帮我查询今天VIP群聊的聊天记录,告诉我有什么值得关注的内容'\n}"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
300,
420
],
"id": "1c015391-f141-4816-9cb6-bfcf6078d26f",
"name": "Code"
}
],
"connections": {
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "获取群聊列表",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "HTTP Request1",
"type": "main",
"index": 0
}
]
]
},
"deep-seek": {
"ai_languageModel": [
[]
]
},
"HTTP Request1": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"获取群聊列表": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"chatlog": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"DeepSeek Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "5832c2da31ff51a8b1ed3cb67fb3a855aeb24f55266b760e465aaa4b262fb4ec"
}
}
本文作者:beq
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!