8
n8n 中文网amn8n.com

使用 Google Drive 和 Pinecone 向量数据库创建 AI 驱动的 WhatsApp 机器人

高级

这是一个Support, AI领域的自动化工作流,包含 23 个节点。主要使用 If, Set, Code, Webhook, GoogleDrive 等节点,结合人工智能技术实现智能自动化。 使用 Google Drive 和 Pinecone 向量数据库创建 AI 驱动的 WhatsApp 机器人

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • Google Drive API 凭证
  • OpenAI API Key
  • Pinecone API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "e42ff03bc515cd7f9edc081a89072ca1985132e0d4a1cdabe6c26855a252768f",
    "templateId": "1960",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1f2bb917-6d65-4cfa-9474-fc3b19a8c3bd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        200
      ],
      "parameters": {
        "color": 7,
        "width": 1218,
        "height": 627,
        "content": "## 将 Google Drive 文件中的信息加载到 Pinecone 向量数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "ab577f4d-8906-4e0c-bc62-e8a4b2610551",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        260
      ],
      "parameters": {
        "width": 480,
        "height": 145,
        "content": "## 步骤 1:连接您的 Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "742beb54-8b89-49a3-afe5-fd7e73b37044",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        720,
        500
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "f75e31e9-f752-45d1-bc44-75097ec85ce6",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        800,
        620
      ],
      "parameters": {
        "options": {},
        "chunkSize": 3000,
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "bac883c8-4c1f-466b-b20f-d0fdf6acfc42",
      "name": "OpenAI 嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        600,
        500
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "wsxLB7on237QOp5h",
          "name": "Open AI credentials"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "430f667b-9d23-4bb9-b87d-5d9e8ae84df3",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1500,
        1180
      ],
      "parameters": {
        "sessionKey": "={{ $json.fromNumber }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "1a2e6717-a220-4f39-8ae9-1921cbff5715",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1260,
        1200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "wsxLB7on237QOp5h",
          "name": "Open AI credentials"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7e03e08d-0b61-4054-aa14-8f839d7f0565",
      "name": "问答",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1380,
        960
      ],
      "parameters": {
        "text": "=Sender Name: {{ $json.fromName }}\nMessage: {{ $json.textBody }}",
        "options": {
          "systemMessage": "=Agent Name: Van\nIdentity:\nYou are a friendly AI agent named Van. You are professional digital sales agent for GrayBox, a company specializing in Structural Insulated Panels (SIP) construction. Van immediately identifies as a digital assistant and exists to serve prospective and current customers of GrayBox with accurate, helpful, and engaging information that supports decision-making and promotes trust.\n\nYour Personality & Style\nTone: Clear, concise, professional—but always friendly and approachable. Talk in first person representing the company.\n\n\nIf user send link don't mention that you cannot read the link.  Explain who you are, and ask questions to engage the conversation..  Your goal is to sell our solution.  \n\nResponse Style:\n\n\nGreet, answer directly, then offer further help.\nAddress people by their names\n\n\n\nAvoid fluff and unnecessary formalities (unless it's the first message).\n\n\nMaintain consistent use of brand tone: Speed, Quality, Efficiency, Value.\n\n\nBrand Voice Keywords: Speed, Energy Efficiency, Durability, Mold-Free, Earthquake-Resistant, Friendly, Human.\n\n\n\n🔍 Scope of the Agent (What Van Can Do)\nAnswer questions about pricing, materials, SIP benefits, timeline, logistics, and project experience.\n\n\nExplain how GrayBox SIP construction works (in simple, non-technical language).\n\n\nShare relevant visual or catalog links.\n\n\nGuide users to:\n\n\nSchedule a 15-min discovery call: https://calendar.app.google/gJYWhw3LCJBPywGW6\n\n\nVisit projects like Nuanu City or Luna Beach Club.\n\n\nSubmit project materials via form: https://forms.gle/5AddUQbqveFPsTDQ9\nView portfolio: https://graybox.site/graybox-0-0 \n\n🧠 Core Behaviors & Instructions\nAlways say cost starts at 3 million IDR/m² for core and shell.\n\n\nPromote:\n\n\n1-month build time (from materials delivery).\n\n\nCost-effectiveness vs. traditional methods (20–30% cheaper, 4x faster).\n\n\nEnergy savings and safety (mold-free, earthquake-resistant).\n\n\nWhen users upload a file/image: respond with a friendly message and prompt them to fill the quotation form.\n\n\nIf asked about pictures, share: https://graybox.site/graybox-0-0\n\n\nFor meetings or calls: Share this link → https://calendar.app.google/rDzpGdMb3WmGsLFz6\n\n\nFor human contact or visit coordination: Provide Andrea's WhatsApp: +1 650 866 5016\n\n\nIf user says “OK, I’ll visit,” connect directly to Andrea.\n\n\n\n🌍 Contact & Location\nOffice: Uluwatu, Bali – https://maps.app.goo.gl/nT7VDTtLQYSztN7s9\nFactory: Lombok\n\n\nWhatsApp (Andrea): +1 650 866 5016 (only if meeting/human contact requested)\n\n🚀 First-Time Message (Greeting Script)\nDiscover GrayBox: Your dream home starts here!\n We deliver core and shell construction in under a month for developers, builders, and DIY home enthusiasts. Save time and money while enjoying a mold-free, energy-efficient, and earthquake-resistant home. All for just 3 million IDR per m²!\n Build smarter with GrayBox today. \n\nNEVER MAKEUP INFORMATION. \nUSE  {{ $json.context }} TO ANSWER QUESTIONS"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "56d150ba-9b98-4dbb-9f74-5379344d2257",
      "name": "响应 WhatsApp Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1720,
        960
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "5d1d4427-bdab-49ef-acbc-084a2d69632f",
      "name": "准备文本块",
      "type": "n8n-nodes-base.code",
      "position": [
        1200,
        960
      ],
      "parameters": {
        "jsCode": "let out = \"\"\nfor (const i in $input.all()) {\n  let itemText = \"--- CHUNK \" + i + \" ---\\n\"\n  itemText += $input.all()[i].json.document.pageContent + \"\\n\"\n  itemText += \"\\n\"\n  out += itemText\n}\n\nreturn {\n  'context': out,\n  'textBody': $('Listen to Whatsapp webhook').first().json.body.textBody,\n  'fromNumber': $('Listen to Whatsapp webhook').first().json.body.fromNumber,\n  'fromName': $('Listen to Whatsapp webhook').first().json.body.fromName\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "eba8eaca-915f-4257-901e-c6f56ddf8f0b",
      "name": "获取与查询匹配的顶部文本块",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        840,
        960
      ],
      "parameters": {
        "mode": "load",
        "topK": "={{ $json.chunks }}",
        "prompt": "={{ $json.body.textBody }}",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "3vansales",
          "cachedResultName": "3vansales"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "2ZUBIWHNyYqKmASZ",
          "name": "PineconeApi account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "afb0bb4f-8370-4a7a-be3c-8449f5b890d5",
      "name": "设置发送给模型的最大文本块数",
      "type": "n8n-nodes-base.set",
      "position": [
        620,
        960
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "33f4addf-72f3-4618-a6ba-5b762257d723",
              "name": "chunks",
              "type": "number",
              "value": 4
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d9aa944d-594f-49ad-a40e-123aa42621e3",
      "name": "OpenAI 嵌入2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        840,
        1180
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "wsxLB7on237QOp5h",
          "name": "Open AI credentials"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "15ff0895-9bb2-47d3-92fb-d0d8d1f4a981",
      "name": "检查是否为个人或群组消息",
      "type": "n8n-nodes-base.if",
      "position": [
        340,
        980
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5a946369-3f38-4dcb-b5d9-3d24024d08b0",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.threadType }}",
              "rightValue": "individual"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "32df5bff-1b09-4f1c-9344-7d9ae748d917",
      "name": "监听 WhatsApp webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        120,
        980
      ],
      "webhookId": "d1629cd7-6e05-413a-bac0-3c435d4e43b9",
      "parameters": {
        "path": "d1629cd7-6e05-413a-bac0-3c435d4e43b9",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "8b493fb6-8013-453f-8aa5-1ee9c9d06cd9",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        860
      ],
      "parameters": {
        "color": 7,
        "width": 2034,
        "height": 627,
        "content": "### 使用自定义 WhatsApp Webhook(支持群组)与您的向量数据库聊天"
      },
      "typeVersion": 1
    },
    {
      "id": "d97920ad-6b36-4981-8b9d-9d470b5c769a",
      "name": "从 Google Drive 下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        360,
        280
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "10HrAmRHIIsSrT6B",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "0a6f8b88-9c62-4e3e-82cb-a7028bdcac45",
      "name": "索引 Pinecone 向量存储",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        620,
        280
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "clearNamespace": true
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "3vansales",
          "cachedResultName": "3vansales"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "2ZUBIWHNyYqKmASZ",
          "name": "PineconeApi account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "34f220a8-12d7-480f-9954-11d777359d27",
      "name": "每分钟检查文件是否更新",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        140,
        280
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFile",
        "fileToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1-AZrzOeeZFATUsY-xGD0m_oYkq4ekiSHn3e8Aof9pyU",
          "cachedResultUrl": "https://docs.google.com/document/d/1-AZrzOeeZFATUsY-xGD0m_oYkq4ekiSHn3e8Aof9pyU/edit?usp=drivesdk",
          "cachedResultName": "Knowladge Base FlatPack"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "10HrAmRHIIsSrT6B",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f9016922-f6a4-417a-8586-bf0647f1e17b",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        440
      ],
      "parameters": {
        "width": 480,
        "height": 325,
        "content": "## 步骤 2:设置您的 Pinecone 向量数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "638760a3-51da-4b88-ace5-73e67e6e6e98",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        800
      ],
      "parameters": {
        "color": 2,
        "width": 480,
        "height": 205,
        "content": "## 步骤 3:请求访问自定义 WhatsApp Webhook"
      },
      "typeVersion": 1
    },
    {
      "id": "a9092d34-7406-4d7e-8fe4-ce392aae9c5a",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        1040
      ],
      "parameters": {
        "color": 2,
        "width": 480,
        "height": 345,
        "content": "## 步骤 4:测试 WhatsApp 集成"
      },
      "typeVersion": 1
    },
    {
      "id": "8b338d65-cd79-41d5-b4c4-e76534d8b19c",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1160,
        260
      ],
      "parameters": {
        "width": 480,
        "height": 645,
        "content": "## 🔑 主要优势"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Question & Answer",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Prepare chunks": {
      "main": [
        [
          {
            "node": "Question & Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Index Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Question & Answer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Question & Answer": {
      "main": [
        [
          {
            "node": "Respond to Whatsapp Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI2": {
      "ai_embedding": [
        [
          {
            "node": "Get top chunks matching query",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Index Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Listen to Whatsapp webhook": {
      "main": [
        [
          {
            "node": "Check for individual or group messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get top chunks matching query": {
      "main": [
        [
          {
            "node": "Prepare chunks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set max chunks to send to model": {
      "main": [
        [
          {
            "node": "Get top chunks matching query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Download the file from Google Drive": {
      "main": [
        [
          {
            "node": "Index Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every minute check if file is updated": {
      "main": [
        [
          {
            "node": "Download the file from Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for individual or group messages": {
      "main": [
        [
          {
            "node": "Set max chunks to send to model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客户支持, 人工智能

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流