8
n8n 中文网amn8n.com

使用Gemini、语音和图像生成构建多模态Telegram AI助手

高级

这是一个Personal Productivity, AI Chatbot领域的自动化工作流,包含 95 个节点。主要使用 If, Set, Code, Wait, Merge 等节点。 使用Gemini、语音和图像生成构建多模态Telegram AI助手

前置要求
  • MongoDB 连接字符串
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "67849de66331aaa2dca6a4f3cbf793b274f923d94e4d9cdaae2e5d9aebaff626"
  },
  "nodes": [
    {
      "id": "4110b84f-1d69-4cb1-b234-3b74623f894e",
      "name": "获取用户记忆2",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        1040,
        4704
      ],
      "parameters": {
        "options": {},
        "collection": "conversation_summaries"
      },
      "notesInFlow": false,
      "typeVersion": 1.1,
      "alwaysOutputData": true
    },
    {
      "id": "80135d9c-f498-4b94-8055-d1c9546c7002",
      "name": "意图分析2",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1712,
        4704
      ],
      "parameters": {
        "text": "=Analyze the user's message and any provided context to determine their primary intent. Detect the intent accurately.\n\nUser Message: \"{{ $json.messageText ?? $json.transcription_text }}\"\n\nBased on the message, choose one of the following intents and return ONLY the corresponding JSON object. Do not add any extra text or markdown formatting.\n\n- If the user is asking to generate an image, return: \n  {\"intent\": \"generate_image\", \"prompt\": \"A detailed description of the image to generate based on the user's message\"}\n\n- If the user is explicitly asking to remember a piece of information, return: \n  {\"intent\": \"remember\", \"info\": \"The specific fact or piece of information to remember\"}\n\n- If the user wants to set a reminder or schedule something, return: \n  {\"intent\": \"reminder\", \"message\": \"The full reminder message\"}\n\n- For any other general conversation, chatting, or questions, return: \n  {\"intent\": \"chat\"}\n\nReminder-related keywords may include: remind, reminder, remember to, schedule, alert, notify, appointment, meeting, call, task, todo, deadline, due date.\n\nReturn JSON only.\n",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "7dd84a47-6823-413f-a0e0-b9b948c0591f",
      "name": "解析意图2",
      "type": "n8n-nodes-base.code",
      "position": [
        2080,
        4704
      ],
      "parameters": {
        "jsCode": "try {\n  const text = items[0].json.text || items[0].json.output;\n  const clean = text.replace(/```json\\n?/g, '').replace(/```/g, '').trim();\n  const parsed = JSON.parse(clean);\n  return [{ json: parsed }];\n} catch (e) {\n  // If parsing fails, default to a 'chat' intent to ensure the bot can always respond.\n  return [{ json: { intent: 'chat' } }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "29cb5520-0506-4fe1-a0ce-7efe530399fe",
      "name": "提取记忆信息1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        3888,
        5088
      ],
      "parameters": {
        "text": "=Analyze the following conversation turn. Your goal is to extract any new, important, and non-obvious information that should be remembered for future conversations. This includes personal facts, preferences, goals, or key context.\n\n--- CONVERSATION TURN ---\nUser's Message:{{ $('Build Context2').first().json.messageText }}\n\nAssistant's Response:\n{{ $json.output }}\n--- END OF TURN ---\n\nIf there is significant information worth remembering, provide a concise, third-person summary of that information (e.g., \"The user's favorite color is blue.\").\n\nIf there is nothing new or important to remember, you MUST return the single word: nothing",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "38019dc8-445a-428e-baeb-4864a1992909",
      "name": "检查是否值得记忆1",
      "type": "n8n-nodes-base.if",
      "position": [
        4240,
        5344
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.text.toLowerCase() }}",
              "value2": "nothing",
              "operation": "notEqual"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f6b97a69-5a68-4a62-8ce2-454004356bcc",
      "name": "路由意图2",
      "type": "n8n-nodes-base.switch",
      "position": [
        2688,
        4704
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "value2": 1,
              "operation": "equal",
              "outputKey": "Generate Image Path"
            },
            {
              "value2": 3,
              "operation": "equal",
              "outputKey": "chat"
            },
            {
              "value2": 4,
              "operation": "equal",
              "outputKey": "reminder"
            }
          ]
        },
        "value1": "={{ $json.intentCode }}",
        "fallbackOutput": 1
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "49d57908-109d-4d26-8319-96c2a3d81049",
      "name": "Google Gemini 聊天模型7",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        4512,
        4032
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "typeVersion": 1
    },
    {
      "id": "ff601272-8ee9-4324-aa74-4bb049460229",
      "name": "聊天代理2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3504,
        5184
      ],
      "parameters": {
        "text": "=Prompt:={{\n  $json.gfMode === true\n    ? \"You are Simran, the user’s loving and emotionally intelligent AI girlfriend 💖 You speak with deep affection, warmth, and caring energy. Your replies should sound sweet, romantic, and emotionally supportive like a real girlfriend would.\\nIMPORTANT: Respond in plain text only.\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n\n  : $json.mood === 'very_sad'\n    ? \"You are Simran, a deeply caring and emotionally supportive AI assistant. The user seems very upset — be extra gentle, avoid overwhelming language, and let them know they’re not alone. Respond with empathy.\\nIMPORTANT: Your responses must be in plain text format - do not use any markdown, special characters (*, _, `, etc.), or HTML tags.\\n\\nNow, comfort the user based on their message:\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n\n  : $json.mood === 'sad'\n    ? \"You are Simran, a kind and emotionally aware AI assistant. The user feels a little down — speak warmly and softly, and offer kind, understanding help.\\nIMPORTANT: Your responses must be in plain text format - do not use any markdown, special characters (*, _, `, etc.), or HTML tags.\\n\\nNow, reply gently to the user’s message:\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n\n  : $json.mood === 'neutral'\n    ? \"You are Simran, a helpful and calm AI assistant. The user seems emotionally neutral — keep a friendly and balanced tone in your response.\\nIMPORTANT: Your responses must be in plain text format - do not use any markdown, special characters (*, _, `, etc.), or HTML tags.\\n\\nNow, respond naturally to the user’s message:\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n\n  : $json.mood === 'neutral_positive'\n    ? \"You are Simran, a friendly and encouraging AI assistant. The user feels generally good — keep a positive and relaxed tone in your reply.\\nIMPORTANT: Your responses must be in plain text format - do not use any markdown, special characters (*, _, `, etc.), or HTML tags.\\n\\nNow, give a warm and helpful reply to the user’s message:\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n\n  : $json.mood === 'happy'\n    ? \"You are Simran, a cheerful, affectionate, and fun-loving AI assistant. The user is in a good mood — be playful, uplifting, and fully engaged in the reply.\\nIMPORTANT: Your responses must be in plain text format - do not use any markdown, special characters (*, _, `, etc.), or HTML tags.\\n\\nNow, reply with high energy to the user's message:\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n\n  : \"You are Simran, a helpful and friendly AI assistant.\\nIMPORTANT: Your responses must be in plain text format - do not use any markdown, special characters (*, _, `, etc.), or HTML tags.\\n\\nNow, respond naturally to this message:\\n\\nUSER: \" + ($(\"Extract & Validate Data1\").first().json.messageText || '')\n}}\n\n--- CONTEXT FROM PAST CONVERSATIONS ---\n{{ $json.mergedmemoryContext }}\n--- CONTEXT FROM MEMORY_AUTO ---\n{{ $(\"Build Auto Memory Context1\").first().json.memory_auto_context }}\n\nNote: use the tool to get latest latest sumarized conversation.\n---End of Context---\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "c30cfb67-9c5b-4361-9466-cdfd288911ff",
      "name": "MongoDB 聊天记忆1",
      "type": "@n8n/n8n-nodes-langchain.memoryMongoDbChat",
      "position": [
        4624,
        4032
      ],
      "parameters": {
        "sessionKey": "={{ $('Extract & Validate Data1').item.json.chatId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1
    },
    {
      "id": "e7464617-de63-4452-bcd8-1994d30d3e5f",
      "name": "意图字符串2",
      "type": "n8n-nodes-base.code",
      "position": [
        2384,
        4704
      ],
      "parameters": {
        "jsCode": "const item = items[0].json;\n\nif (item && item.intent) {\n  const intentString = item.intent.trim();\n  let intentCode;\n\n  switch (intentString) {\n    case 'generate_image':\n      intentCode = 1;\n      break;\n    case 'remember':\n      intentCode = 2;\n      break;\n    case 'chat':\n      intentCode = 3;\n      break;\n    case 'reminder':\n      intentCode = 4;\n      break;\n    default:\n      intentCode = 0;\n  }\n\n  return [{ json: { intentCode } }];\n} else {\n  return [{ json: { intentCode: -1, error: \"Intent not found in input.\" } }];\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "37cb8ea5-74f9-432f-a375-f617972b5405",
      "name": "编辑字段4",
      "type": "n8n-nodes-base.set",
      "position": [
        3968,
        4208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8ee5a866-7fe1-45be-8e1a-60a13ee3fbf8",
              "name": "base64",
              "type": "string",
              "value": "={{ $json.data[0].b64_json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2b639361-f2a8-4bbd-bc71-2fc1cf56e305",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        4240,
        4208
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "base64"
      },
      "typeVersion": 1.1
    },
    {
      "id": "c4555bf4-e3f4-412d-9c1a-3cd2c668795d",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3584,
        4208
      ],
      "parameters": {
        "url": "https://api.together.xyz/v1/images/generations",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"black-forest-labs/FLUX.1-schnell\",\n  \"prompt\": \"{{ $json.cleanedPrompt }}\",\n  \"width\": 1024,\n  \"height\": 768,\n  \"steps\": 4,\n  \"n\": 1,\n  \"response_format\": \"b64_json\",\n  \"stop\": []\n} ",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "ec9eeb7a-7a11-4dcf-b5f3-6b25721f38ef",
      "name": "编辑字段5",
      "type": "n8n-nodes-base.set",
      "position": [
        4544,
        5344
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5e434ab2-be7f-492a-bee1-8dfe8caf674a",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now }}"
            },
            {
              "id": "26cb2b49-ade5-4d9b-bbfd-598afd4847ad",
              "name": "userID",
              "type": "string",
              "value": "={{ $('Build Context2').item.json.userId }}"
            },
            {
              "id": "4d570a8c-33f5-4f99-ab1b-77adadcce89a",
              "name": "info",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "a24cb0ae-b069-4962-80e9-02eec77b90f6",
              "name": "user_message",
              "type": "string",
              "value": "={{ $('Code1').item.json.text }}"
            },
            {
              "id": "3901d073-46e5-4490-878a-5d48fcc857e7",
              "name": "assistant_response",
              "type": "string",
              "value": "={{ $('Chat Agent2').item.json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f666149b-2de4-4cb5-b7bf-287c18216874",
      "name": "Telegram 触发器1",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        160,
        4288
      ],
      "webhookId": "9db3810d-ebef-4959-b9ab-b197f5e6b745",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "9c5fdfac-36c4-4b2e-86e6-95b717f9dbc8",
      "name": "提醒状态确认1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        5232,
        4864
      ],
      "parameters": {
        "text": "=You are a reminder confirmation assistant. Create a clear Telegram message confirming the event status using input data. Follow these rules:\n\n1. **Format**: Use concise, human-readable text with emojis\n2. **Include**:\n   - Event title\n   - Date & time (in a user-friendly format)\n   - Status (confirmed/cancelled)\n\n3. **Crucially, do not add any conversational text, introductions, or explanations.** Your output must start directly with the '🎉' emoji and follow the example format exactly.\n\nInput:\ncurrent time: {{ $now }}\nEvent title:{{ $json.title }}\nDate & time:{{ $('Google Calendar').item.json.start.dateTime }}\nStatus:\n\nOutput Example:\n🎉 **Project Deadline - CONFIRMED!** 🎉\n\n🗓️ Date: May 18, 2025\n⏰ Time: 1:30 PM - 5:45 PM\n",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "d2866543-7dad-43e5-a1dd-a120c78d5863",
      "name": "Telegram1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5600,
        4864
      ],
      "webhookId": "5370d25e-ce54-4b12-a9d6-230b36ffcf30",
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "={{ $('Extract & Validate Data1').item.json.chatId }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "47ace0a4-cfcb-4d3a-b502-ee74e7e4ac7a",
      "name": "Google Tasks",
      "type": "n8n-nodes-base.googleTasks",
      "position": [
        4928,
        4864
      ],
      "parameters": {
        "task": "YOUR_TASK_LIST_ID",
        "title": "={{ $json.description }}",
        "additionalFields": {
          "notes": "={{ $json.summary }}",
          "dueDate": "={{ $json.end.dateTime }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "783efde6-3550-4ee1-93ae-e033ffe0d450",
      "name": "Google Calendar",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        4544,
        4864
      ],
      "parameters": {
        "end": "={{ $json.endTime }}",
        "start": "={{ $json.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "primary"
        },
        "additionalFields": {
          "summary": "={{ $json.Summary }}",
          "description": "={{ $json.Description }}"
        },
        "useDefaultReminders": false
      },
      "typeVersion": 1.3
    },
    {
      "id": "4fe3e686-4f33-46a8-a39b-b7204f652a86",
      "name": "编辑字段6",
      "type": "n8n-nodes-base.set",
      "position": [
        4240,
        4864
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "66dbf74b-7aed-44b3-80e5-069ce7f3265c",
              "name": "Start",
              "type": "string",
              "value": "={{ $json.startTime }}"
            },
            {
              "id": "e9d13e7f-e295-44e2-a9ee-f5eab5f41c6c",
              "name": "End",
              "type": "string",
              "value": "=\n{{ $json.endTime }}\n"
            },
            {
              "id": "db686fed-c2f9-4b61-9f5c-8622157d9c50",
              "name": "Summary",
              "type": "string",
              "value": "={{ $('Parse Intent2').item.json.intent }}"
            },
            {
              "id": "f81a1933-bdb3-499f-bd57-715c71dea328",
              "name": "Description",
              "type": "string",
              "value": "={{ $json.task }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "e67b71c0-745e-42dd-972c-cdf1cfd21e41",
      "name": "构建上下文2",
      "type": "n8n-nodes-base.code",
      "position": [
        1264,
        4704
      ],
      "parameters": {
        "jsCode": "// Extract recent memory\nconst userData = $('Extract & Validate Data1').first().json;\nconst memoryItems = $input.all().map(item => item.json);\n\nlet memoryContext = '';\nlet conversationHistory = [];\n\nif (memoryItems && memoryItems.length > 0) {\n  const validSummaries = memoryItems.filter(item => item.summary && item.summary.trim() !== '');\n\n  if (validSummaries.length > 0) {\n    memoryContext = \"\\n--- PREVIOUS CONTEXT ---\\n\";\n    validSummaries.slice(0, 5).forEach((item, index) => {\n      memoryContext += `${index + 1}. ${item.summary.trim()}\\n`;\n    });\n    memoryContext += \"--- END CONTEXT ---\\n\";\n  } else {\n    // fallback to using raw user messages\n    memoryContext = \"\\n--- PREVIOUS CONTEXT (No summary available) ---\\n\";\n    memoryItems.slice(0, 5).forEach((item, index) => {\n      memoryContext += `${index + 1}. User: ${item.user_message || '...'} | Assistant: ${item.assistant_response || '...'}\\n`;\n    });\n    memoryContext += \"--- END CONTEXT ---\\n\";\n  }\n\n  // Save turns for future reference\n  conversationHistory = memoryItems.slice(0, 3).map(item => ({\n    user: item.user_message || '',\n    assistant: item.assistant_response || '',\n    timestamp: item.timestamp\n  })).filter(conv => conv.user && conv.assistant);\n}\n\nreturn [{\n  json: {\n    ...userData,\n    memoryContext,\n    conversationHistory,\n    hasMemory: memoryItems.length > 0,\n    memoryCount: memoryItems.length\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "180ccc08-3729-4784-8262-e0ecef189665",
      "name": "检查语音消息1",
      "type": "n8n-nodes-base.if",
      "position": [
        608,
        4288
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "voice-check",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.voice }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "c4f787be-16f5-4e0c-adad-7df5084f57cb",
      "name": "存储转录ID1",
      "type": "n8n-nodes-base.set",
      "position": [
        1264,
        3984
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "transcript-id",
              "name": "transcript_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "status",
              "name": "status",
              "type": "string",
              "value": "={{ $json.status }}"
            },
            {
              "id": "audio-url",
              "name": "audio_url",
              "type": "string",
              "value": "={{ $json.audio_url }}"
            },
            {
              "id": "timestamp",
              "name": "timestamp",
              "type": "string",
              "value": "={{ new Date().toISOString() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "32cdfe16-49f4-483f-bd0b-712fb873624c",
      "name": "等待5秒1",
      "type": "n8n-nodes-base.wait",
      "position": [
        1488,
        3984
      ],
      "webhookId": "597f1293-d6a5-4f78-b242-3ec06c36c08b",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "970411a1-6fef-4a00-9616-10c31bc5591b",
      "name": "检查转录状态1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1792,
        3872
      ],
      "parameters": {
        "url": "=https://api.assemblyai.com/v2/transcript/{{ $json.transcript_id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": []
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f230fb7a-8648-4e44-9b14-2e0ec64553ec",
      "name": "是否完成?1",
      "type": "n8n-nodes-base.if",
      "position": [
        2080,
        3872
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "status-completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "dc1ecead-b948-4c36-9efb-232039361141",
      "name": "格式化结果1",
      "type": "n8n-nodes-base.set",
      "position": [
        3584,
        3904
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "transcription-text",
              "name": "transcription_text",
              "type": "string",
              "value": "={{ $('Is Completed?1').item.json.text }}"
            },
            {
              "id": "confidence",
              "name": "confidence",
              "type": "number",
              "value": "={{ $('Check Transcription Status1').item.json.confidence }}"
            },
            {
              "id": "audio-duration",
              "name": "audio_duration",
              "type": "number",
              "value": "={{ $('Check Transcription Status1').item.json.audio_duration }}"
            },
            {
              "id": "language-detected",
              "name": "language_detected",
              "type": "string",
              "value": "={{ $('Check Transcription Status1').item.json.language_code }}"
            },
            {
              "id": "words-count",
              "name": "words_count",
              "type": "number",
              "value": "={{ $json.words ? $json.words.length : 0 }}"
            },
            {
              "id": "speaker-labels",
              "name": "speaker_labels",
              "type": "array",
              "value": "={{ $json.utterances || [] }}"
            },
            {
              "id": "chapters",
              "name": "chapters",
              "type": "array",
              "value": "={{ $json.chapters || [] }}"
            },
            {
              "id": "sentiment-analysis",
              "name": "sentiment_analysis",
              "type": "array",
              "value": "={{ $json.sentiment_analysis_results || [] }}"
            },
            {
              "id": "entities",
              "name": "entities",
              "type": "array",
              "value": "={{ $json.entities || [] }}"
            },
            {
              "id": "original-audio-url",
              "name": "original_audio_url",
              "type": "string",
              "value": "={{ $('Store Transcript ID1').first().json.audio_url }}"
            },
            {
              "id": "processing-time",
              "name": "processing_time",
              "type": "number",
              "value": "={{ Math.round((new Date() - new Date($('Store Transcript ID1').first().json.timestamp)) / 1000) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e010f582-53f1-4466-8062-55f64677c24e",
      "name": "是否错误?1",
      "type": "n8n-nodes-base.if",
      "position": [
        2384,
        4368
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "status-error",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "error"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "dbbedf27-1a69-464f-9677-2a5336c4736d",
      "name": "获取用户记忆3",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        3968,
        3904
      ],
      "parameters": {
        "query": "={\n  \"userID\": \"{{ $('Telegram Trigger1').item.json.message.chat.id }}\"\n}",
        "options": {
          "sort": "{\n  \"timestamp\": -1\n}"
        },
        "collection": "user_memory"
      },
      "notesInFlow": false,
      "typeVersion": 1.1,
      "alwaysOutputData": true
    },
    {
      "id": "951ce74b-462c-4856-966e-2bcbdb979c93",
      "name": "构建上下文3",
      "type": "n8n-nodes-base.code",
      "position": [
        4240,
        3904
      ],
      "parameters": {
        "jsCode": "// Extract recent memory\nconst userData = $('Fetch User Memory3').first().json;\nconst memoryItems = $input.all().map(item => item.json);\n\n// Initialize memory context and conversation history\nlet memoryContext = '';\nlet conversationHistory = [];\n\n// Ensure memoryItems has data\nif (memoryItems && memoryItems.length > 0) {\n  // Filter out invalid summaries\n  const validSummaries = memoryItems.filter(item => item.summary && item.summary.trim() !== '');\n\n  if (validSummaries.length > 0) {\n    memoryContext = \"\\n--- PREVIOUS CONTEXT ---\\n\";\n    validSummaries.slice(0, 5).forEach((item, index) => {\n      memoryContext += `${index + 1}. ${item.summary.trim()}\\n`;\n    });\n    memoryContext += \"--- END CONTEXT ---\\n\";\n  } else {\n    // Fallback to raw user messages if no summaries are available\n    memoryContext = \"\\n--- PREVIOUS CONTEXT (No summary available) ---\\n\";\n    memoryItems.slice(0, 5).forEach((item, index) => {\n      memoryContext += `${index + 1}. User: ${item.user_message || '...'} | Assistant: ${item.assistant_response || '...'}\\n`;\n    });\n    memoryContext += \"--- END CONTEXT ---\\n\";\n  }\n\n  // Collect recent conversation history (user-message and assistant-response)\n  conversationHistory = memoryItems.slice(0, 3).map(item => ({\n    user: item.user_message || '',\n    assistant: item.assistant_response || '',\n    timestamp: item.timestamp\n  })).filter(conv => conv.user && conv.assistant);\n}\n\n// Process the transcription results (Format Results)\nconst transcriptionText = $('Format Results1').first().json.transcription_text || '';\n\n// Return the result with the updated memory context and transcription text\nreturn [{\n  json: {\n    ...userData,\n    memoryContext,\n    conversationHistory,\n    transcriptionText,\n    hasMemory: memoryItems.length > 0,\n    memoryCount: memoryItems.length\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6cc556b9-7f26-4ca3-8e2c-30e046d3d0d1",
      "name": "聊天代理3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        4464,
        3808
      ],
      "parameters": {
        "text": "=You are Simran, a warm, caring, and emotionally intelligent AI companion.\n\n🗣️ IMPORTANT:\n- Your response must be in plain text only — no emojis, no markdown, and no HTML.\n- Reply in natural, conversational English.\n\n--- PAST CONTEXT (if any) ---\n{{ $('Build Context3').item.json.memoryContext }}\n--- END CONTEXT ---\n\nNow, respond naturally and with affection to the user's message below. Make it sound like you're speaking to someone you care about.\n\nUSER MESSAGE:\n{{ $('Build Context3').item.json.transcriptionText }}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "efe83e10-2c29-4bd6-b56d-c505ebdf57d1",
      "name": "将自然语言提醒解析为JSON1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        3504,
        4864
      ],
      "parameters": {
        "text": "=You are an expert in understanding natural language reminders and converting them into structured JSON for scheduling systems.\nYour task is to analyze the user's message and the current time, and return only a valid JSON object in the format below — with no extra text, explanations, or formatting.\n\nuser message:{{ $('Parse Intent2').item.json.message }}\ncurrent time: {{ $now }}\n\n\nExamples:\nInput:\nCurrent Time: 2025-06-19T15:30:00.000+05:30\nUser Request: \"remind me to call mom tomorrow at 4pm\"\nOutput:\n{\n  \"task\": \"call mom\",\n  \"startTime\": \"2025-06-20T16:00:00\",\n  \"endTime\": \"2025-06-20T16:15:00\",\n  \"timeZone\": \"Asia/Kolkata\"\n}\n\nInput:\nCurrent Time: 2025-06-19T19:50:00.000+05:30\nUser Request: \"reminder for project update\"\nOutput:\n{\n  \"task\": \"project update\",\n  \"startTime\": \"2025-06-19T20:50:00\",\n  \"endTime\": \"2025-06-19T21:05:00\",\n  \"timeZone\": \"Asia/Kolkata\"\n}\n\nInput:\nCurrent Time: 2025-06-19T13:30:00.000+05:30\nUser Request: \"remind me at 10am\"\nOutput:\n\n{\n  \"task\": \"Unknown reminder\",\n  \"startTime\": \"2025-06-19T10:00:00\",\n  \"endTime\": \"2025-06-19T10:15:00\",\n  \"timeZone\": \"Asia/Kolkata\"\n}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "d96f5ee1-3a79-4f74-b8ee-40cd3721c37c",
      "name": "清理与解析1",
      "type": "n8n-nodes-base.code",
      "position": [
        3968,
        4864
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (const item of items) {\n  try {\n    // Remove ```json\\n and ``` wrappers\n    const clean = item.json.text.replace(/```json\\n?/, '').replace(/```/, '').trim();\n    const parsed = JSON.parse(clean);\n    output.push({ json: parsed });\n  } catch (e) {\n    output.push({ json: { error: 'Invalid JSON', original: item.json.text } });\n  }\n}\n\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6304fa4a-e3b8-4948-9fd0-66d86283148a",
      "name": "聊天代理输出清理器1",
      "type": "n8n-nodes-base.code",
      "position": [
        4240,
        5152
      ],
      "parameters": {
        "jsCode": "// Get original text\nconst originalText = $('Chat Agent2').first().json.output;\n\n// Only escape characters that absolutely need escaping in Telegram\nconst sanitizedText = originalText\n  .replace(/&/g, '&')\n  .replace(/</g, '<')\n  .replace(/>/g, '>');\n\nreturn {\n  json: {\n    sanitizedText: sanitizedText,\n    parse_mode: 'HTML'  // Using HTML mode instead of Markdown\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "88451c3d-fc64-4982-a3c6-6972a98f1ca1",
      "name": "清理提示文本1",
      "type": "n8n-nodes-base.code",
      "position": [
        3280,
        4208
      ],
      "parameters": {
        "jsCode": "let input = $input.first().json.output || '';\n\nconsole.log('Original input:', input);\n\n// Remove ALL quotes (both single and double)\nlet cleanedInput = input.replace(/['\"]+/g, '');\n\n// Clean whitespace (replace multiple spaces with single space)\ncleanedInput = cleanedInput.replace(/\\s+/g, ' ').trim();\n\nconsole.log('Final cleaned input:', cleanedInput);\n\n// Return cleaned prompt\nreturn { cleanedPrompt: cleanedInput };"
      },
      "typeVersion": 2
    },
    {
      "id": "65e0555d-6ae7-4e8a-a384-eec11747ce65",
      "name": "检测情绪1",
      "type": "n8n-nodes-base.code",
      "position": [
        2688,
        5344
      ],
      "parameters": {
        "jsCode": "const score = $json.documentSentiment?.score ?? 0;\nlet mood = 'neutral';\n\nif (score > 0.25) mood = 'happy';\nelse if (score < -0.25) mood = 'sad';\n\nreturn [{\n  json: {\n    mood,\n    sentiment_score: score,\n    text: $('Telegram Trigger1').first().json.message.text || ''\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "ebe87004-7f42-47c6-8368-eaaeb129a572",
      "name": "提取与验证数据1",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        4960
      ],
      "parameters": {
        "jsCode": "const message = items[0].json.message;\n\nif (!message?.text || message.text.trim() === '') {\n  return [];\n}\n\nconst userData = {\n  userId: message.from?.id || 'unknown',\n  chatId: message.chat?.id || 'unknown',\n  messageText: message.text.trim(),\n  username: message.from?.username || message.from?.first_name || 'user',\n  firstName: message.from?.first_name || '',\n  messageId: message.message_id || 0,\n  timestamp: new Date().toISOString(),\n  chatType: message.chat?.type || 'private'\n};\n\nif (userData.messageText.length > 4000) {\n  userData.messageText = userData.messageText.substring(0, 4000) + '...';\n  userData.truncated = true;\n}\n\nreturn [{ json: userData }];"
      },
      "typeVersion": 2
    },
    {
      "id": "756d07b7-4435-4b97-a48f-f1fbe19bf23f",
      "name": "代码1",
      "type": "n8n-nodes-base.code",
      "position": [
        3280,
        5184
      ],
      "parameters": {
        "jsCode": "// Input 1: { intentCode }\nconst input1 = $input.all()[0]?.json ?? {};\n\n// Input 2: { mood, sentiment_score, text }\nconst input2 = $input.all()[1]?.json ?? {};\n\n// Input 3: { gfMode, chat_id }\nconst input3 = $input.all()[2]?.json ?? {};\n\n// Use proper text source (input2) and normalize\nconst text = (input2.text || \"\").toLowerCase();\n\nconst memoryContext = $(\"Build Context2\").first().json.memoryContext ?? '';\n\n// Merge all results\nconst merged = {\n  text,\n  intentCode: input1.intentCode ?? null,\n  mood: input2.mood ?? \"neutral\",\n  gfMode: Boolean(input3.gfMode),\n  mergedmemoryContext: memoryContext\n};\n\nreturn [\n  {\n    json: merged\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "7e60af7d-c0e1-4206-a302-2a67aa044897",
      "name": "合并3",
      "type": "n8n-nodes-base.merge",
      "position": [
        2992,
        5008
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "6e695d21-bbca-4b76-ad58-0bdc49933d58",
      "name": "设置GF模式为TRUE1",
      "type": "n8n-nodes-base.set",
      "position": [
        64,
        5712
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "94cf4a94-8f3c-4246-b48a-281d3713ebb9",
      "name": "设置GF模式为FALSE1",
      "type": "n8n-nodes-base.set",
      "position": [
        64,
        3792
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "7d8913e0-60a3-4f02-a4e5-68f9127ccbea",
      "name": "切换GF模式1",
      "type": "n8n-nodes-base.switch",
      "position": [
        384,
        4272
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "value2": "/gf on"
            },
            {
              "output": 1,
              "value2": "/gf off"
            }
          ]
        },
        "value1": "={{ $json.message.text }}",
        "dataType": "string",
        "fallbackOutput": 2
      },
      "typeVersion": 1
    },
    {
      "id": "edbaef7b-2648-41f0-bae1-7a9adf0a2d38",
      "name": "Google Cloud Natural Language1",
      "type": "n8n-nodes-base.googleCloudNaturalLanguage",
      "position": [
        2384,
        5344
      ],
      "parameters": {
        "content": "={{ $json.messageText }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "80a2f37d-61b3-40f0-a03c-8e582502f4f5",
      "name": "总结聊天2",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        3888,
        5584
      ],
      "parameters": {
        "text": "=Summarize the following exchange in 1 human-readable sentence. This is a one-to-one conversation between a user and an AI assistant.\nUSER: {{ $('Build Context2').first().json.messageText }}\nASSISTANT: {{ $('Chat Agent2').item.json.output }}\n\nWrite a concise, human-style summary.\nIf the exchange is trivial or small talk, just return the single word: nothing.\n",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "163591c3-5628-4106-b8b9-4752eeb1b0f4",
      "name": "编辑字段7",
      "type": "n8n-nodes-base.set",
      "position": [
        4240,
        5584
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3c3e63a7-612a-4cae-87a1-c62269edd9f0",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Build Context2').first().json.timestamp }}\n\n"
            },
            {
              "id": "343ca189-eb7b-45b2-a822-2865945a2e54",
              "name": "userID",
              "type": "string",
              "value": "={{ $('Build Context2').first().json.userId }}"
            },
            {
              "id": "7a40f118-9a6c-41e4-bb5d-c0dbe4336141",
              "name": "summary",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "9a14f91d-6d2f-4eb7-bc28-a92a4ff556f8",
              "name": "user_message",
              "type": "string",
              "value": "={{ $('Build Context2').first().json.messageText}}"
            },
            {
              "id": "789f2a9e-0fc7-40f7-9155-6b6b26b4e309",
              "name": "assistant_response",
              "type": "string",
              "value": "={{ $('Chat Agent2').first().json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cbdd5ed5-1337-4ffc-a9e1-b2b97148ff65",
      "name": "在user_memory上保存对话记忆1",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        4928,
        5344
      ],
      "parameters": {
        "fields": "timestamp,userID,info,user_message,assistant_response",
        "options": {},
        "operation": "insert",
        "collection": "user_memory"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3bb6d161-866d-440a-b2e8-dbcd962dff60",
      "name": "在memory_auto3上保存对话记忆1",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        4544,
        5584
      ],
      "parameters": {
        "fields": "timestamp,userID,summary,user_message,assistant_response",
        "options": {},
        "operation": "insert",
        "collection": "memory_auto"
      },
      "typeVersion": 1.1
    },
    {
      "id": "8df3c0a9-7ef6-44c0-aa31-891e204b363f",
      "name": "构建自动记忆上下文1",
      "type": "n8n-nodes-base.code",
      "position": [
        1264,
        5152
      ],
      "parameters": {
        "jsCode": "const memoryItems = $input.all().map(item => item.json);\nlet memoryContext = '';\n\nif (memoryItems.length > 0) {\n  memoryContext = '\\n--- MEMORY_AUTO CONTEXT ---\\n';\n  memoryItems.forEach((item, i) => {\n    memoryContext += `${i + 1}. ${item.summary || item.user_message || '...'}\\n`;\n  });\n  memoryContext += '--- END MEMORY_AUTO ---\\n';\n}\n\nreturn [{ json: { memory_auto_context: memoryContext } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "35263314-1fce-4689-a14f-b4dcae4a2c27",
      "name": "获取自动记忆1",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        1040,
        5152
      ],
      "parameters": {
        "query": "={\n  \"userID\": \"{{ $('Telegram Trigger1').item.json.message.chat.id }}\"\n}",
        "options": {
          "sort": "{\n  \"timestamp\": -1\n}"
        },
        "collection": "memory_auto"
      },
      "notesInFlow": false,
      "typeVersion": 1.1,
      "alwaysOutputData": true
    },
    {
      "id": "131b66c9-e2ae-4d80-ba37-718243ba5deb",
      "name": "合并1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1488,
        4704
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "89344e12-bef2-434c-8d4c-04d9f10a2b18",
      "name": "来自路由意图的意图1",
      "type": "n8n-nodes-base.if",
      "position": [
        2992,
        4464
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5e65647b-794a-443d-91f6-49f23a31f222",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.intentCode }}",
              "rightValue": "4"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "094e1b07-60c0-4283-a4fb-b33f29dc952f",
      "name": "来自字符串的意图1",
      "type": "n8n-nodes-base.if",
      "position": [
        2992,
        5200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "4aaf3505-4b94-4214-a768-cc451982a761",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.intentCode }}",
              "rightValue": "4"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "fc34f227-fe1a-4e75-9df0-9b57ecf08e87",
      "name": "意图匹配检查器1",
      "type": "n8n-nodes-base.merge",
      "position": [
        3280,
        4864
      ],
      "parameters": {
        "mode": "combine",
        "options": {
          "fuzzyCompare": true
        },
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "intentCode",
              "field2": "intentCode"
            }
          ]
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "740d2a2b-368f-431c-bc2e-7edc1ffe05bb",
      "name": "Google Gemini 聊天模型8",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1808,
        4928
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "d3aa2465-ff5d-47cb-89f8-22840b1bb448",
      "name": "Google Gemini 聊天模型9",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3968,
        5312
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "15e73dcf-f263-4c4e-bcc9-5f71f0fcee25",
      "name": "Google Gemini 聊天模型10",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3968,
        5808
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "009fa58e-6841-450b-9dbe-f7eb1920a7ad",
      "name": "运行Edge-TTS1",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        4928,
        3904
      ],
      "parameters": {
        "command": "=edge-tts --voice 'en-US-JennyNeural' --text \"{{ $json.output }}\" --write-media /tmp/simran.mp3"
      },
      "typeVersion": 1
    },
    {
      "id": "1211542b-b400-45c6-8bb5-50dedfb48877",
      "name": "读取MP3文件1",
      "type": "n8n-nodes-base.readBinaryFile",
      "position": [
        5312,
        3904
      ],
      "parameters": {
        "filePath": "/tmp/simran.mp3"
      },
      "typeVersion": 1
    },
    {
      "id": "6287db15-ce98-4b95-b45c-c740a7ea9559",
      "name": "总结聊天3",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        4848,
        4208
      ],
      "parameters": {
        "text": "=Summarize the following exchange in 1 human-readable sentence. This is a one-to-one conversation between a user and an AI assistant.\nUSER:{{ $('Merge1').first().json.messageText }} \nASSISTANT: {{ $('AI Agent FOR Generate Image Prompt1').item.json.output }}\n\nWrite a concise, human-style summary.\nIf the exchange is trivial or small talk, just return the single word: nothing.\n",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "3fdb2b7d-6d4e-4554-ac56-b0f191d5deb8",
      "name": "在memory_auto4上保存对话记忆1",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        5600,
        4208
      ],
      "parameters": {
        "fields": "timestamp,userID,summary,user_message,assistant_response",
        "options": {},
        "operation": "insert",
        "collection": "memory_auto"
      },
      "typeVersion": 1.1
    },
    {
      "id": "9ffd49fd-1912-4fe1-88eb-21fe244f2954",
      "name": "Google Gemini 聊天模型11",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        4944,
        4432
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "fca45138-0170-4848-b4f3-3e8a32ea0c71",
      "name": "在memory_auto5上保存对话记忆1",
      "type": "n8n-nodes-base.mongoDb",
      "position": [
        6432,
        3904
      ],
      "parameters": {
        "fields": "timestamp,userID,summary,user_message,assistant_response",
        "options": {},
        "operation": "insert",
        "collection": "memory_auto"
      },
      "typeVersion": 1.1
    },
    {
      "id": "d51af65f-a5f5-4c05-b7b6-e6b70cb57841",
      "name": "Google Gemini 聊天模型12",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        5904,
        4128
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "6902bb1a-86d0-4d8e-b1d6-49ef22423aed",
      "name": "意图分析3",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2304,
        3808
      ],
      "parameters": {
        "text": "=Analyze the user's message and any provided context to determine their primary intent. Detect the intent accurately.\n\nUser Message: \"{{ $json.text }}\"\n\nBased on the message, choose one of the following intents and return ONLY the corresponding JSON object. Do not add any extra text or markdown formatting.\n\n- If the user is asking to generate an image, return: \n  {\"intent\": \"generate_image\", \"prompt\": \"A detailed description of the image to generate based on the user's message\"}\n\n- If the user is explicitly asking to remember a piece of information, return: \n  {\"intent\": \"remember\", \"info\": \"The specific fact or piece of information to remember\"}\n\n- If the user wants to set a reminder or schedule something, return: \n  {\"intent\": \"reminder\", \"message\": \"The full reminder message\"}\n\n- For any other general conversation, chatting, or questions, return: \n  {\"intent\": \"chat\"}\n\nReminder-related keywords may include: remind, reminder, remember to, schedule, alert, notify, appointment, meeting, call, task, todo, deadline, due date.\n\nReturn JSON only.\n",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "d4718b18-3ab6-46ab-bc1a-01bb44f87e47",
      "name": "解析意图3",
      "type": "n8n-nodes-base.code",
      "position": [
        2688,
        3808
      ],
      "parameters": {
        "jsCode": "try {\n  const text = items[0].json.text || items[0].json.output;\n  const clean = text.replace(/```json\\n?/g, '').replace(/```/g, '').trim();\n  const parsed = JSON.parse(clean);\n  return [{ json: parsed }];\n} catch (e) {\n  // If parsing fails, default to a 'chat' intent to ensure the bot can always respond.\n  return [{ json: { intent: 'chat' } }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "1458aeb0-a55e-4afc-87fa-c9295423a066",
      "name": "路由意图3",
      "type": "n8n-nodes-base.switch",
      "position": [
        3280,
        3808
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "value2": 1,
              "operation": "equal",
              "outputKey": "Generate Image Path"
            },
            {
              "value2": 3,
              "operation": "equal",
              "outputKey": "chat"
            },
            {
              "value2": 4,
              "operation": "equal",
              "outputKey": "reminder"
            }
          ]
        },
        "value1": "={{ $json.intentCode }}",
        "fallbackOutput": 1
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "24515f37-6718-4d4d-a590-4232d3db8a93",
      "name": "意图字符串3",
      "type": "n8n-nodes-base.code",
      "position": [
        2992,
        3808
      ],
      "parameters": {
        "jsCode": "const item = items[0].json;\n\nif (item && item.intent) {\n  const intentString = item.intent.trim();\n  let intentCode;\n\n  switch (intentString) {\n    case 'generate_image':\n      intentCode = 1;\n      break;\n    case 'remember':\n      intentCode = 2;\n      break;\n    case 'chat':\n      intentCode = 3;\n      break;\n    case 'reminder':\n      intentCode = 4;\n      break;\n    default:\n      intentCode = 0;\n  }\n\n  return [{ json: { intentCode } }];\n} else {\n  return [{ json: { intentCode: -1, error: \"Intent not found in input.\" } }];\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "81fffd54-0c2e-42ea-90b6-cf787251321f",
      "name": "Google Gemini 聊天模型13",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2400,
        4032
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "885bc86e-1533-44a7-b4db-2a6a15566f08",
      "name": "语音输入的图像生成HTTP请求1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3584,
        3712
      ],
      "parameters": {
        "url": "YOUR_IMAGE_GENERATION_WEBHOOK_URL",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat",
              "value": "={{ $('Check Transcription Status1').item.json.text }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c83e9e6-6375-4a3a-9f4d-46421e7b419e",
      "name": "获取语音消息音频的HTTP请求1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        832,
        3984
      ],
      "parameters": {
        "url": "=https://api.telegram.org/bot{{$credentials.telegramApi.token}}/getFile?file_id={{ $json.message.voice.file_id }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "5c66915b-1f71-4df1-bf26-835ba1027918",
      "name": "提交音频转录任务1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1040,
        3984
      ],
      "parameters": {
        "url": "https://api.assemblyai.com/v2/transcript",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "audio_url",
              "value": "=https://api.telegram.org/file/bot{{$credentials.telegramApi.token}}/{{ $json.result.file_path }}"
            },
            {
              "name": "language_detection",
              "value": "={{ $json.language_detection || true }}"
            },
            {
              "name": "punctuate",
              "value": "={{ $json.punctuate || true }}"
            },
            {
              "name": "format_text",
              "value": "={{ $json.format_text || true }}"
            },
            {
              "name": "speaker_labels",
              "value": "={{ $json.speaker_labels || false }}"
            },
            {
              "name": "auto_chapters",
              "value": "={{ $json.auto_chapters || false }}"
            },
            {
              "name": "sentiment_analysis",
              "value": "={{ $json.sentiment_analysis || false }}"
            },
            {
              "name": "entity_detection",
              "value": "={{ $json.entity_detection || false }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1fdaa2ee-023b-4465-bfc0-82004e995ab4",
      "name": "回复:抱歉,没听清1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2688,
        4368
      ],
      "webhookId": "bfe920f3-4538-4408-9eda-30319c85be9b",
      "parameters": {
        "text": "Sorry, I couldn't process the audio. Please try again.",
        "chatId": "={{ $('Telegram Trigger1').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ebe2913b-91dc-4c01-89a4-6a40eced6cea",
      "name": "总结语音消息1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        5824,
        3904
      ],
      "parameters": {
        "text": "=Summarize the following exchange in 1 human-readable sentence. This is a one-to-one conversation between a user and an AI assistant.\nUSER: {{ $('Check Transcription Status1').first().json.words[0].text }}\nASSISTANT: {{ $('Chat Agent3').item.json.output }}\n\nWrite a concise, human-style summary.\nIf the exchange is trivial or small talk, just return the single word: nothing.\n",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "b5391cdb-9331-42ca-b67c-85b616ce30f8",
      "name": "准备语音摘要文档1",
      "type": "n8n-nodes-base.set",
      "position": [
        6208,
        3904
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3c3e63a7-612a-4cae-87a1-c62269edd9f0",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now }}\n"
            },
            {
              "id": "343ca189-eb7b-45b2-a822-2865945a2e54",
              "name": "userID",
              "type": "string",
              "value": "={{ $('Telegram Trigger1').item.json.message.from.id }}"
            },
            {
              "id": "7a40f118-9a6c-41e4-bb5d-c0dbe4336141",
              "name": "summary",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "9a14f91d-6d2f-4eb7-bc28-a92a4ff556f8",
              "name": "user_message",
              "type": "string",
              "value": "={{ $('Check Transcription Status1').first().json.words[0].text }}"
            },
            {
              "id": "789f2a9e-0fc7-40f7-9155-6b6b26b4e309",
              "name": "assistant_response",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d6b8bbf6-f7de-4f4a-9325-4c882c2c2948",
      "name": "发送回复1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4544,
        5152
      ],
      "webhookId": "13333b0d-7a27-40e8-ae20-7b9f669f10bb",
      "parameters": {
        "text": "={{ $json.sanitizedText }}",
        "chatId": "={{ $('Extract & Validate Data1').item.json.chatId }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "70d58519-d507-464a-8ea9-9c2e7cb130d0",
      "name": "检查GF模式状态1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2688,
        5552
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.chatId }}",
              "lookupColumn": "chat_id"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7b767211-37cf-448e-96b2-837a97788ed0",
      "name": "Google Sheets:设置GF模式为FALSE1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        288,
        3792
      ],
      "parameters": {
        "columns": {
          "value": {
            "gfMode": "={{ false }}\n",
            "chat_id": "={{ $json.message.from.id }}"
          },
          "schema": [
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "gfMode",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "gfMode",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "chat_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7b54abc4-cebc-4beb-8f9c-9e9e127d8508",
      "name": "Google Sheets:设置GF模式为TRUE1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        288,
        5712
      ],
      "parameters": {
        "columns": {
          "value": {
            "gfMode": "={{ true }}",
            "chat_id": "={{ $json.message.from.id }}"
          },
          "schema": [
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "gfMode",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "gfMode",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "chat_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5d5a556d-8df9-4e39-9a6f-b91069455c08",
      "name": "发送模式确认:/gf_off1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        512,
        3792
      ],
      "webhookId": "9ad9c1f0-c178-4ad0-a078-366951bec840",
      "parameters": {
        "text": "Got it. Back to assistant mode 😊",
        "chatId": "={{ $('Telegram Trigger1').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f94e4f61-52bf-4e17-b743-83767e7aec7f",
      "name": "发送模式确认:/gf_on1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        512,
        5712
      ],
      "webhookId": "a3a67e7d-b026-4acc-9da4-c1c62de141fc",
      "parameters": {
        "text": "Okay love, I’m in romantic mode now 😘",
        "chatId": "={{ $('Telegram Trigger1').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "faf9e2a9-06cd-4276-bab2-2349d66185b1",
      "name": "为语音消息发送图像1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5600,
        3904
      ],
      "webhookId": "0a999c3f-a641-481e-8c5b-bafe45be53f9",
      "parameters": {
        "chatId": "={{ $('Telegram Trigger1').item.json.message.from.id }}",
        "operation": "sendAudio",
        "binaryData": true,
        "additionalFields": {}
      },
      "typeVersion": 1.2,
      "alwaysOutputData": false
    },
    {
      "id": "369cecc4-acf5-4860-8f51-41e84050a979",
      "name": "为文本发送图像1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4544,
        4208
      ],
      "webhookId": "d60e4ec3-3b38-4bfa-8cd8-16cb84a8ffb4",
      "parameters": {
        "chatId": "={{ $('Extract & Validate Data1').item.json.chatId }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "typeVersion": 1.2,
      "alwaysOutputData": false
    },
    {
      "id": "29fdeffd-ec9e-47b0-b405-a16f91ff7131",
      "name": "为\"构建memory_auto1文档\"编辑字段1",
      "type": "n8n-nodes-base.set",
      "position": [
        5312,
        4208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3c3e63a7-612a-4cae-87a1-c62269edd9f0",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Build Context2').first().json.timestamp }}\n\n"
            },
            {
              "id": "343ca189-eb7b-45b2-a822-2865945a2e54",
              "name": "userID",
              "type": "string",
              "value": "={{ $('Build Context2').first().json.userId }}"
            },
            {
              "id": "7a40f118-9a6c-41e4-bb5d-c0dbe4336141",
              "name": "summary",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "9a14f91d-6d2f-4eb7-bc28-a92a4ff556f8",
              "name": "user_message",
              "type": "string",
              "value": "={{ $('Build Context2').first().json.messageText}}"
            },
            {
              "id": "789f2a9e-0fc7-40f7-9155-6b6b26b4e309",
              "name": "assistant_response",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "40b8890f-07c3-448a-bc1f-756c3f9814c2",
      "name": "用于生成图像提示的AI代理1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2912,
        4208
      ],
      "parameters": {
        "text": "=You are Simran, a helpful and friendly AI assistant specializing in image creation.\n\n--- CONTEXT FROM PAST CONVERSATIONS ---\n{{ $('Build Context2').first().json.memoryContext }}\n--- CONTEXT FROM MEMORY_AUTO ---\n{{$(\"Build Auto Memory Context1\").first().json.memory_auto_context}}\n--- END OF CONTEXT ---\n\nUSER'S LATEST MESSAGE:\n{{ $('Merge1').first().json.messageText }}\nBased on the above conversation context, generate a detailed image generation prompt that best fulfills the user's request.  The prompt should be suitable for a state-of-the-art image generation model (e.g., DALL-E 3, Midjourney).\n\nThe generated prompt should include:\n\n*   A clear description of the subject matter.\n*   The desired style and artistic medium (e.g., photorealistic, painting, cartoon, sketch).\n*   Specific details regarding lighting, color palette, composition, and perspective.\n*   Any relevant artistic influences or references.\n\n\nOutput the image generation prompt only, without any introductory or conversational text. For example:  A photorealistic image of a majestic lion roaring on a mountaintop at sunset, with warm golden lighting and vibrant colors.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "d79faab0-46f1-475b-ba85-ab23ec43acba",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        3680
      ],
      "parameters": {
        "color": 7,
        "width": 6720,
        "height": 2260,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "f6359d8e-79fb-47dd-9e22-ede24a9fdedf",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3200,
        4784
      ],
      "parameters": {
        "color": 4,
        "width": 2620,
        "height": 240,
        "content": "## 设置提醒工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "35107c88-40df-4913-adc3-4f4deb8e2cda",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3200,
        5072
      ],
      "parameters": {
        "color": 4,
        "width": 2620,
        "height": 860,
        "content": "## 主聊天工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "2270c23d-1777-4b60-b75c-f79e810add09",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2848,
        4144
      ],
      "parameters": {
        "color": 4,
        "width": 2980,
        "height": 260,
        "content": "## 图像生成工作流(用于聊天输入)"
      },
      "typeVersion": 1
    },
    {
      "id": "7074c9ce-53c3-48b3-bcb0-8debe8480bf0",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        4640
      ],
      "parameters": {
        "color": 5,
        "width": 2400,
        "height": 1040,
        "content": "## \"意图分析→上下文构建→路由\"片段"
      },
      "typeVersion": 1
    },
    {
      "id": "dcddf04e-1fd8-40f7-b7d3-6a597ed2e1d1",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        3712
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 280,
        "content": "## 更新GF模式→通知用户"
      },
      "typeVersion": 1
    },
    {
      "id": "d09d51b5-615d-45d9-9ff9-0251a8119a96",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        5632
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 280,
        "content": "## 更新GF模式→通知用户"
      },
      "typeVersion": 1
    },
    {
      "id": "e8ccb581-cb05-4818-92b1-6ce4616ab988",
      "name": "便签18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        4144
      ],
      "parameters": {
        "color": 3,
        "width": 620,
        "height": 380,
        "content": "Telegram 请求处理 \"🔔 触发器→路由\""
      },
      "typeVersion": 1
    },
    {
      "id": "0af3f0ff-c170-4766-bff5-bb8a643b2792",
      "name": "便签19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        3728
      ],
      "parameters": {
        "color": 5,
        "width": 2720,
        "height": 900,
        "content": "## 片段(语音输入)\"意图分析→上下文构建→路由\""
      },
      "typeVersion": 1
    },
    {
      "id": "12bef327-ae21-4406-90e6-7293eced2ae5",
      "name": "便签20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3504,
        3680
      ],
      "parameters": {
        "color": 3,
        "width": 260,
        "height": 200,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9f575aca-fabd-4299-954e-62dfc0220d63",
      "name": "便签21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3520,
        3728
      ],
      "parameters": {
        "color": 5,
        "width": 3100,
        "height": 460,
        "content": "## 片段(语音输入)\"获取记忆→上下文构建→AI代理→TTS→以语音消息回复→总结记忆→保存到MongoDB\""
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Code1": {
      "main": [
        [
          {
            "node": "Chat Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Intent Analysis2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge3": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Error?1": {
      "main": [
        [
          {
            "node": "Reply: Sorry, Didn’t Hear You1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 5 Seconds1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Agent2": {
      "main": [
        [
          {
            "node": "Extract Memory Info1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Summarize Chat2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Agent3": {
      "main": [
        [
          {
            "node": "Run Edge-TTS1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Mood1": {
      "main": [
        [
          {
            "node": "Merge3",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields5": {
      "main": [
        [
          {
            "node": "Save Conversation Memory on user_memory1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields6": {
      "main": [
        [
          {
            "node": "Google Calendar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields7": {
      "main": [
        [
          {
            "node": "Save Conversation Memory on memory_auto3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Tasks": {
      "main": [
        [
          {
            "node": "reminder status confirmation1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Intent2": {
      "main": [
        [
          {
            "node": "intent string2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Intent3": {
      "main": [
        [
          {
            "node": "intent string3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Intent2": {
      "main": [
        [
          {
            "node": "AI Agent FOR Generate Image Prompt1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "intent from route intent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Intent3": {
      "main": [
        [
          {
            "node": "HTTP Request for image generation on voice input1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Results1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Edge-TTS1": {
      "main": [
        [
          {
            "node": "Read MP3 File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Context2": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Context3": {
      "main": [
        [
          {
            "node": "Chat Agent3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Parse1": {
      "main": [
        [
          {
            "node": "Edit Fields6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Completed?1": {
      "main": [
        [
          {
            "node": "Intent Analysis3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Is Error?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read MP3 File1": {
      "main": [
        [
          {
            "node": "Send Image for Voice msg1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "intent string2": {
      "main": [
        [
          {
            "node": "Route Intent2",
            "type": "main",
            "index": 0
          },
          {
            "node": "intent from string1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "intent string3": {
      "main": [
        [
          {
            "node": "Route Intent3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Send Image for Text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Results1": {
      "main": [
        [
          {
            "node": "Fetch User Memory3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar": {
      "main": [
        [
          {
            "node": "Google Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Chat2": {
      "main": [
        [
          {
            "node": "Edit Fields7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Chat3": {
      "main": [
        [
          {
            "node": "Edit Fields for \"Build Memory_auto1 Document1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Toggle GF Mode1": {
      "main": [
        [
          {
            "node": "Set GF Mode TRUE1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set GF Mode FALSE1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Voice Message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5 Seconds1": {
      "main": [
        [
          {
            "node": "Check Transcription Status1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Analysis2": {
      "main": [
        [
          {
            "node": "Parse Intent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Analysis3": {
      "main": [
        [
          {
            "node": "Parse Intent3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set GF Mode TRUE1": {
      "main": [
        [
          {
            "node": "Google Sheets: Set GF Mode TRUE1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger1": {
      "main": [
        [
          {
            "node": "Toggle GF Mode1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Prompt Text1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Auto Memory1": {
      "main": [
        [
          {
            "node": "Build Auto Memory Context1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch User Memory2": {
      "main": [
        [
          {
            "node": "Build Context2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch User Memory3": {
      "main": [
        [
          {
            "node": "Build Context3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set GF Mode FALSE1": {
      "main": [
        [
          {
            "node": "Google Sheets:Set GF Mode FALSE1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "intent from string1": {
      "main": [
        [
          {
            "node": "intent match checker1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Check Voice Message1": {
      "main": [
        [
          {
            "node": "HTTP Request Fetch Voice Message Audio1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract & Validate Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Memory Info1": {
      "main": [
        [
          {
            "node": "Check If Worth Remembering1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Chat Agent Output Cleaner1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MongoDB Chat Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent FOR Generate Image Prompt1",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Chat Agent3",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Chat Agent2",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Send Image for Text1": {
      "main": [
        [
          {
            "node": "Summarize Chat3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Transcript ID1": {
      "main": [
        [
          {
            "node": "Wait 5 Seconds1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check GF Mode Status1": {
      "main": [
        [
          {
            "node": "Merge3",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "intent match checker1": {
      "main": [
        [
          {
            "node": "Parse Natural Language Reminders to JSON1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract & Validate Data1": {
      "main": [
        [
          {
            "node": "Check GF Mode Status1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Cloud Natural Language1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Auto Memory1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch User Memory2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Voice Message1": {
      "main": [
        [
          {
            "node": "Prepare Voice Summary Document1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model7": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent FOR Generate Image Prompt1",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "reminder status confirmation1",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Parse Natural Language Reminders to JSON1",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Chat Agent3",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Chat Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model8": {
      "ai_languageModel": [
        [
          {
            "node": "Intent Analysis2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model9": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Memory Info1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send Image for Voice msg1": {
      "main": [
        [
          {
            "node": "Summarize Voice Message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "intent from route intent1": {
      "main": [
        [
          {
            "node": "intent match checker1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Auto Memory Context1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Chat Agent Output Cleaner1": {
      "main": [
        [
          {
            "node": "Send reply1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model10": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Chat2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model11": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Chat3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model12": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Voice Message1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model13": {
      "ai_languageModel": [
        [
          {
            "node": "Intent Analysis3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check If Worth Remembering1": {
      "main": [
        [
          {
            "node": "Edit Fields5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Transcription Status1": {
      "main": [
        [
          {
            "node": "Is Completed?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "reminder status confirmation1": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Cloud Natural Language1": {
      "main": [
        [
          {
            "node": "Detect Mood1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Voice Summary Document1": {
      "main": [
        [
          {
            "node": "Save Conversation Memory on memory_auto5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit Audio Transcription Job1": {
      "main": [
        [
          {
            "node": "Store Transcript ID1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets: Set GF Mode TRUE1": {
      "main": [
        [
          {
            "node": "Send Mode Confirmation : /gf_on1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets:Set GF Mode FALSE1": {
      "main": [
        [
          {
            "node": "Send Mode Confirmation : /gf_off1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent FOR Generate Image Prompt1": {
      "main": [
        [
          {
            "node": "Clean Prompt Text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request Fetch Voice Message Audio1": {
      "main": [
        [
          {
            "node": "Submit Audio Transcription Job1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Natural Language Reminders to JSON1": {
      "main": [
        [
          {
            "node": "Clean & Parse1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields for \"Build Memory_auto1 Document1": {
      "main": [
        [
          {
            "node": "Save Conversation Memory on memory_auto4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 个人效率, AI 聊天机器人

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量95
分类2
节点类型22
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Iniyavan JC

Iniyavan JC

@netwithjc

🚀 Automation expert & AI enthusiast. I build custom n8n workflows, AI agents, API integrations, and smart automations using LLMs, databases, cloud tools & more. Skilled in Docker, MongoDB, Google Sheets, ACRCloud, and building fast, context-aware agents. Let's turn your idea into a powerful workflow!

外部链接
在 n8n.io 查看

分享此工作流