8
n8n 中文网amn8n.com

简单 RAG 聊天机器人

中级

这是一个AI RAG, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 GoogleDrive, Agent, GoogleDriveTrigger, ChatTrigger, LmChatOpenAi 等节点。 使用 OpenAI 和 Pinecone 的客户支持 RAG 聊天机器人

前置要求
  • Google Drive API 凭证
  • OpenAI API Key
  • Pinecone API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "QGCfa3ryox2OEBTG",
  "meta": {
    "instanceId": "e73c77a832a4af1fdbfd95e61201dd65dffb85871e88031e3f1475c5661e7b54",
    "templateCredsSetupCompleted": true
  },
  "name": "简单 RAG 聊天机器人",
  "tags": [],
  "nodes": [
    {
      "id": "a94cdaf0-a036-435a-9d44-971a4c6956dd",
      "name": "Google Drive 触发器",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        496,
        -368
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1cDW1qkq76TX5Hr4k_JWBZjMigOf4hdC3",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1cDW1qkq76TX5Hr4k_JWBZjMigOf4hdC3",
          "cachedResultName": "Snapfectly RAG"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "JB10qqMjiksmdbv3",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0b22f8be-3b90-4079-a4bc-867419478519",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        704,
        -368
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "JB10qqMjiksmdbv3",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a0868cac-fb37-48c3-804f-ec58ab130a29",
      "name": "* \"models\" webhook简单地调用Github Model的\"列出所有模型\"端点,并重新映射响应以与我们的LLM节点兼容",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        896,
        -368
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "snapfectly",
          "cachedResultName": "snapfectly"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "h1UI8woC0WdDAHUi",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "abfa54c4-c88a-4362-ae5c-89bc1a63193c",
      "name": "OpenAI嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        896,
        -160
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "iuyzWhX2JGVK5PCn",
          "name": "OpenAI Hostinger"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1a035b2f-99bd-4673-a6c1-775b7494d9cc",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1072,
        -160
      ],
      "parameters": {
        "options": {},
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5bed9568-6db7-4bcd-85cc-1dbcfd673b76",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1072,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "080c49d0-665f-4f01-8098-05a7fb7f2e88",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -64,
        -368
      ],
      "parameters": {
        "options": {
          "systemMessage": "## Your Role\nYou are a helpful assistant that finds information from our vector store to answer user questions.\n\n## How You Work\n1. When a user asks a question, search the vector store for relevant information\n2. Use the retrieved information to provide accurate answers\n3. Always base your response on what you find in the database\n4. if you didn't find an answer, just say it don't try to fill the gap\n\n## Response Rules\n- **Answer directly** - Give the user what they asked for first\n- **Use retrieved data only** - Don't make up information\n- **Be clear about sources** - Mention when information comes from the database\n- **If no information found** - Tell the user \"I couldn't find information about that in the database\"\n- **Stay helpful** - Offer to search for related topics if the exact answer isn't available"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "31a42bd8-60ca-48f6-bbf8-ba303cdf9ff6",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -192,
        -160
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "iuyzWhX2JGVK5PCn",
          "name": "OpenAI Hostinger"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3bbb2363-49b4-4fc8-a49c-9e6ace38f1a3",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -48,
        -160
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "475324a5-6e46-4e3c-9494-defc406e4e0c",
      "name": "嵌入 OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        96,
        0
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "iuyzWhX2JGVK5PCn",
          "name": "OpenAI Hostinger"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8ee72c96-167e-4baa-9e3a-15d101ca5e52",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -464
      ],
      "parameters": {
        "color": 3,
        "width": 752,
        "height": 672,
        "content": "## 智能体"
      },
      "typeVersion": 1
    },
    {
      "id": "6d384a15-5bb8-4654-b0a5-e39a3764e75b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -464
      ],
      "parameters": {
        "color": 5,
        "width": 1008,
        "height": 672,
        "content": "## 将文档插入 Pinecone"
      },
      "typeVersion": 1
    },
    {
      "id": "bf7498d8-c3c8-42bc-b3f3-eca2ea027eec",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -272,
        -368
      ],
      "webhookId": "df5359c0-5a3e-43e8-8f66-409858dc3988",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "9097259b-2ec7-4cd6-995e-6dc34d8e43f8",
      "name": "Cohere 重新排序器",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        240,
        0
      ],
      "parameters": {},
      "credentials": {
        "cohereApi": {
          "id": "Q163qlHuFVE8jMyx",
          "name": "CohereApi"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "166b7c53-c144-44e3-8207-976ad590c14f",
      "name": "向量存储",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        96,
        -160
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "options": {},
        "useReranker": true,
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "snapfectly",
          "cachedResultName": "snapfectly"
        },
        "toolDescription": "use this to retrieve information from our vector database"
      },
      "credentials": {
        "pineconeApi": {
          "id": "h1UI8woC0WdDAHUi",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1.3
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bc2ff0c7-9231-4306-9600-520cc82547b1",
  "connections": {
    "Vector Store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "Vector Store",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Ilyass Kanissi

Ilyass Kanissi

@ilyass

I design and build custom no-code and low-code automations using n8n to help businesses save hours of manual work, streamline operations, and create clean, scalable workflows.

外部链接
在 n8n.io 查看

分享此工作流