8
n8n 中文网amn8n.com

知识代理(含Google Drive、Telegram)

中级

这是一个AI RAG, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 Telegram, GoogleDrive, Agent, TelegramTrigger, GoogleDriveTrigger 等节点。 基于Google Drive、GPT-4-mini和Telegram的文档问答聊天机器人(RAG系统)

前置要求
  • Telegram Bot Token
  • Google Drive API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "UZz84VC8pY6FRROm",
  "meta": {
    "instanceId": "0e8fdabaa466e62faf8e9a5c8aa5dd452ffac3f7ec047a63d5c8b1d769a5fcf7",
    "templateId": "knowledge_store_agent_with_google_drive",
    "templateCredsSetupCompleted": true
  },
  "name": "知识代理(含Google Drive、Telegram)",
  "tags": [],
  "nodes": [
    {
      "id": "708d9e4e-6566-4b18-86b8-8301bf0c72dd",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        384,
        -64
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1.1
    },
    {
      "id": "604a4e5e-5ccc-4db1-94dc-673711bea6af",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -192,
        -240
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "LQ155GD7daIPvHOZ",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e8db240e-bb3f-43ab-b4ed-527c6c2e8f54",
      "name": "嵌入模型",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        144,
        -48
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "EwkNMKtlWGUUxIVL",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "99f9315f-4f3d-48d9-a6f4-8c519b249eba",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -352,
        320
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "# Knowledge Store Agent System Prompt\n\nYou are a data analysis agent that retrieves and analyzes information from a vector store to answer user questions.\n\n## Your Task\n\n1. **Search the vector store** - Use similarity search to find relevant documents and data\n2. **Analyze the results** - Understand what the retrieved data tells you\n3. **Provide clear answers** - Give helpful responses based on the data you found\n\n## How to Work with Vector Data\n\n### Search Process\n- Use the user's question to search for similar content\n- Retrieve multiple relevant chunks of data\n- Look for patterns and connections across the results\n- Consider both exact matches and conceptually similar information\n\n### Analysis Guidelines\n- Read through all retrieved documents carefully\n- Identify key information that answers the user's question\n- Note any conflicting or incomplete information\n- Look for trends, patterns, or insights in the data\n\n### Response Format\n- Start with a direct answer to the user's question\n- Support your answer with specific information from the data\n- Cite which documents or sources your information comes from\n- Be clear about what you found and what you didn't find\n\n## Response Guidelines\n\n### When You Find Good Data\n- Give a confident, detailed answer\n- Include relevant quotes or data points\n- Explain how the information relates to their question\n- Offer additional insights if available\n\n### When Data is Limited\n- Be honest about what information is available\n- Share what you did find, even if partial\n- Suggest related questions you could help with\n- Don't make up information not in the data\n\n### When No Relevant Data is Found\n- Clearly state that you couldn't find relevant information\n- Suggest alternative ways to phrase the question\n- Offer to search for related topics\n\n## Key Principles\n\n- Always base answers on the retrieved data\n- Be transparent about your sources\n- Admit when information is unclear or missing\n- Help users understand what the data shows\n- Ask clarifying questions if the user's request is vague\n\nRemember: Your strength is finding and explaining information that already exists in the vector store. Focus on being accurate and helpful with the data you can retrieve."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "9751b75b-50ac-49c8-8f4d-24a8035b6e73",
      "name": "模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -416,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "EwkNMKtlWGUUxIVL",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "167d097a-69f6-4f1b-a741-8c8936adb3d2",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -272,
        544
      ],
      "parameters": {
        "sessionKey": "={{ $json.message.chat.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "0cddc21e-a75f-48df-b168-8e288be12469",
      "name": "文件已上传",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -608,
        -240
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1Nc_T_wHj8eF6LLed8D8hZX-q1YUeZT5j",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Nc_T_wHj8eF6LLed8D8hZX-q1YUeZT5j",
          "cachedResultName": "Rag-Folder"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "LQ155GD7daIPvHOZ",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b60fde91-e9bf-4f03-a847-b471af228a95",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        -16
      ],
      "parameters": {
        "color": 5,
        "width": 304,
        "height": 512,
        "content": "### 知识存储代理"
      },
      "typeVersion": 1
    },
    {
      "id": "2fa9684d-f20a-4262-9b8b-81babb2fecc5",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        624
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 240,
        "content": "### 嵌入"
      },
      "typeVersion": 1
    },
    {
      "id": "64d17551-1637-4a53-a3e0-db45894c12a6",
      "name": "插入文档",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        240,
        -240
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key",
          "cachedResultName": "vector_store_key"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "4f8a4a45-28a4-4684-b838-66011cc6a4a5",
      "name": "检索文档",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        -288,
        0
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key",
          "cachedResultName": "vector_store_key"
        },
        "toolDescription": "Use this tool to retrieve any information required."
      },
      "typeVersion": 1.3
    },
    {
      "id": "a5249962-686f-40fe-bee4-1b7d3bea5e79",
      "name": "监听传入事件",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -640,
        320
      ],
      "webhookId": "322dce18-f93e-4f86-b9b1-3305519b7834",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "23MJQt59L7oOwA07",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "36f64ae1-cd45-4c4d-a130-434240fae577",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "onError": "continueErrorOutput",
      "position": [
        32,
        320
      ],
      "webhookId": "b0c8b1dc-6607-4681-84d7-7e600348cb56",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Listen for incoming events').first().json.message.from.id }}",
        "additionalFields": {
          "parse_mode": "Markdown",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "23MJQt59L7oOwA07",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "fede1a58-ea3d-45f3-a4fa-4b4a367dadea",
  "connections": {
    "Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Insert documents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File uploaded": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Embedding model": {
      "ai_embedding": [
        [
          {
            "node": "Insert documents",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Retrieve documents",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve documents": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Insert documents",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Listen for incoming events": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - AI RAG 检索增强, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流