8
n8n 中文网amn8n.com

AI驱动的WhatsApp聊天机器人

高级

这是一个Support Chatbot, AI RAG领域的自动化工作流,包含 35 个节点。主要使用 Set, Code, Switch, WhatsApp, GoogleDocs 等节点。 使用GPT-4o-mini和MongoDB为文档构建RAG驱动的WhatsApp聊天机器人

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
  • MongoDB 连接字符串
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "vYWjlJAfDq1CLvwh",
  "meta": {
    "instanceId": "6c1bc30b5f087d2b3635d5a895d4ebe581394ab9a8f14e320c3671f4d1070a12",
    "templateCredsSetupCompleted": true
  },
  "name": "AI 驱动的 WhatsApp 聊天机器人",
  "tags": [],
  "nodes": [
    {
      "id": "8b5a6eb6-0b15-489d-b122-3e49ead07d44",
      "name": "知识库代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3140,
        1020
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": ""
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "7de6ec3d-0160-4e52-a457-cb8e4695a631",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        3140,
        1200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "t3h6MkO3IXeZM0oN",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ab9c5096-543a-4b6c-a67f-59e048fb6a49",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3480,
        1360
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "t3h6MkO3IXeZM0oN",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3b4a0e5c-17f1-47e7-9501-0fc58fb09eba",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        800,
        60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "cf33740a-db43-4dd8-a4fc-f4304e2dca26",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        3240,
        1200
      ],
      "parameters": {
        "sessionKey": "=memory_{{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "aac65924-febe-487f-8aaa-66160e1d68cd",
      "name": "MongoDB 向量搜索",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        3360,
        1200
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "toolName": "productDocs",
        "mongoCollection": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-template",
          "cachedResultName": "n8n-template"
        },
        "toolDescription": "retreive documentation",
        "vectorIndexName": "data_index"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ba9ee299-ba87-4d3b-85ab-342eb1a36333",
      "name": "文档分段加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1340,
        220
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "doc_id",
                "value": "={{ $json.documentId }}"
              }
            ]
          }
        },
        "jsonData": "={{ $json.content }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1
    },
    {
      "id": "903ed5a6-ef8d-4e8f-a8ed-69c471696ec7",
      "name": "文档分块器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1340,
        360
      ],
      "parameters": {
        "options": {
          "splitCode": "markdown"
        },
        "chunkSize": 3000,
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "b7d20587-58c9-4ed3-92af-7866d21929d0",
      "name": "MongoDB 向量存储插入器",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        1240,
        60
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "mongoCollection": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-template",
          "cachedResultName": "n8n-template"
        },
        "vectorIndexName": "data_index"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e3fdc76a-58d0-4313-a2e2-3a05e9e69587",
      "name": "OpenAI 嵌入生成器",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1240,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "577f8392-10cd-44e0-9cac-17d87b2a76ba",
      "name": "Google Docs 导入器",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1020,
        60
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/1gvgp71e9edob8WLqFIYCdzC7kUq3pLO37VKb-a-vVW4/edit?tab=t.0"
      },
      "typeVersion": 2
    },
    {
      "id": "b1f0160f-6b7d-4b6a-89e0-55f98f2d1279",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        40
      ],
      "parameters": {
        "color": 5,
        "content": "手动运行此工作流,将 Google Docs 产品文档导入 MongoDB 并建立向量嵌入索引以实现快速搜索。"
      },
      "typeVersion": 1
    },
    {
      "id": "a0aee202-897a-4680-9b65-2a2b6cb39d19",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        980
      ],
      "parameters": {
        "color": 4,
        "height": 280,
        "content": "此工作流监听 WhatsApp 消息(文本、音频、图像、文档),将其转换为嵌入向量,搜索 MongoDB,并使用 GPT-4o-mini 提供具有对话记忆的上下文感知回答。"
      },
      "typeVersion": 1
    },
    {
      "id": "cc9e1076-fd72-48df-a930-5133bb6895ef",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1640,
        40
      ],
      "parameters": {
        "height": 540,
        "content": "搜索索引示例"
      },
      "typeVersion": 1
    },
    {
      "id": "c8ec72a1-70de-4a91-9569-cd5773f6f77e",
      "name": "WhatsApp 触发器",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        800,
        1020
      ],
      "webhookId": "ab09ca3e-53b2-4079-9ddc-bccb2f69551b",
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "id": "JZmd3JpbRgS6dKRd",
          "name": "WhatsApp OAuth account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bf60f6ef-e838-4961-8a21-ad0c6317e523",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1880,
        780
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "translate"
      },
      "credentials": {
        "openAiApi": {
          "id": "t3h6MkO3IXeZM0oN",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "ed3a0719-8dd8-4f29-a15c-9910872682c5",
      "name": "OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1880,
        1020
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {
          "detail": "auto"
        },
        "resource": "image",
        "inputType": "base64",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "id": "t3h6MkO3IXeZM0oN",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "f8fb7589-56d8-43b2-81cd-09a0b578fb7b",
      "name": "从 PDF 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2480,
        1480
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "c7684d79-a21a-4914-bd11-8158210ae9bd",
      "name": "从 XLS 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2380,
        1680
      ],
      "parameters": {
        "options": {},
        "operation": "xls"
      },
      "typeVersion": 1
    },
    {
      "id": "9fd46ff5-f7ac-4aaa-a4b0-1ef043115838",
      "name": "从 XLSX 文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2380,
        1840
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "1b574602-e308-4f5d-bf38-480c68e90232",
      "name": "映射 JSON",
      "type": "n8n-nodes-base.set",
      "position": [
        2620,
        1600
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "72ae0d20-616a-4a65-9b14-53bf53656091",
              "name": "data",
              "type": "string",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cd49a4c3-019b-4bf0-bf38-21a05421c890",
      "name": "映射文件扩展名",
      "type": "n8n-nodes-base.code",
      "position": [
        1840,
        1360
      ],
      "parameters": {
        "jsCode": "let requests = $(\"Download Document\").all()\n\nrequests.forEach((request) => {\n  let mime_type = request.json.mime_type\n\n  if (\n    mime_type === \"text/calendar\" || \n    mime_type === \"application/ics\" || \n    mime_type === \"text/x-calendar\"\n  ) {\n    request.json.mime_type = \"mapped/calendar\"\n  }\n\n  if (\n    mime_type === \"application/xml\" || \n    mime_type === \"text/xml\") {\n    request.json.mime_type = \"mapped/xml\"\n  }\n\n  if (!mime_type) {\n    request.json.mime_type = $('Gets WhatsApp Document Source URL').first().json.mime_type\n  }\n})\n\nreturn requests;"
      },
      "typeVersion": 2
    },
    {
      "id": "57a371b1-86b7-4191-a8a7-aa1c2a9fca40",
      "name": "映射文档提示",
      "type": "n8n-nodes-base.set",
      "position": [
        2860,
        1420
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "da68bcca-a2a6-4676-8649-6fb1b664e44c",
              "name": "text",
              "type": "string",
              "value": "=Parsed text: {{ $json.text || $json.data || $json }}\n\nCaption text: {{ $('Route Types').item.json.messages[0].document.caption }}\n\nMimeType: {{ $('Gets WhatsApp Document Source URL').item.json.mime_type }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3cd05ec3-e093-4be1-98c2-b34513770e37",
      "name": "映射图像提示",
      "type": "n8n-nodes-base.set",
      "position": [
        2100,
        1020
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "48af2dcc-4ce9-45fc-abfc-54f803930092",
              "name": "text",
              "type": "string",
              "value": "=User image description: {{ $json.content }}\n\nUser image caption: {{ $('Route Types').item.json.messages[0].image.caption }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "693f234d-dbe3-4330-ade1-d7e3d9e5d9dd",
      "name": "映射文本提示",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        580
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "38aec976-a32c-4b0e-85f4-c90adc16abc9",
              "name": "text",
              "type": "string",
              "value": "={{ $json.messages[0].text.body }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "577e4532-bd7e-4f7d-a2d2-3abdaf9d2c67",
      "name": "获取 WhatsApp 语音邮件源 URL",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1440,
        780
      ],
      "webhookId": "bbe62f3d-8788-49d4-aae6-9e9411446d44",
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.messages[0].audio.id}}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "LSWzVTg64cAdpkcw",
          "name": "WhatsApp account 3"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "acad9ee7-4928-4629-908f-4741a1aadc82",
      "name": "获取 WhatsApp 图像源 URL",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1440,
        1020
      ],
      "webhookId": "c2982df4-1d8d-4669-a724-44ae17d11e6c",
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.messages[0].image.id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "LSWzVTg64cAdpkcw",
          "name": "WhatsApp account 3"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a5fe7973-74e9-4343-b3a4-bfe5ee4b40bb",
      "name": "获取 WhatsApp 文档源 URL",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1440,
        1360
      ],
      "webhookId": "c2982df4-1d8d-4669-a724-44ae17d11e6c",
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.messages[0].document.id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "LSWzVTg64cAdpkcw",
          "name": "WhatsApp account 3"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1347ee86-eeb4-4d7d-909a-df956b131ac1",
      "name": "下载语音邮件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1660,
        780
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "HbkIqe4va08FNkZq",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "de8d1488-d892-499f-b5f4-f5c6e97b8296",
      "name": "下载图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1660,
        1020
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "HbkIqe4va08FNkZq",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5cf698c8-ae35-4c8a-804b-4c5ab2424468",
      "name": "下载文档",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1660,
        1360
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {}
          }
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "HbkIqe4va08FNkZq",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b6d7f091-5ec9-44e0-aba5-7c5468cc0790",
      "name": "路由类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        1020,
        1000
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2fc5c912-629b-4cbe-b5e3-7e3f0651c628",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.messages[0].type }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "26a3d85c-0815-48ff-85ce-713129a1107c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.messages[0].type }}",
                    "rightValue": "audio"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "840b95b8-6559-4fb7-b32c-651451d6d0d2",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.messages[0].type }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Document",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3e7a07f9-b785-450c-8c68-f6b276838503",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.messages[0].type }}",
                    "rightValue": "document"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "002800e0-712e-4ab8-a1fd-befbe2f0681b",
      "name": "路由文档类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        2100,
        1200
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "CSV",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "14e23243-cd44-4cb1-99bd-9e6905d511ad",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "text/csv"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "HTML",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6d7616c5-6bdd-47b7-923e-639491d15a4e",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "text/html"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Calendar",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a2174e02-378a-41ff-b269-61f4fc3f1de9",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "=mapped/calendar"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "RTF",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f3b406d7-362d-473e-8edd-c3e5f2d9c44c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "text/rtf"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "TXT",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "64dd4658-54e7-4453-adbc-7067dffcd555",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "text/plain"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "XML",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7540a3ab-b48e-4bec-94e9-a5dfc3d65a4c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "mapped/xml"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "PDF",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "88b618fd-9a88-491e-91dd-c5fc9efa36e3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "application/pdf"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "JSON",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9c4d90aa-b4ea-4a63-b15e-666899c8360e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "application/json"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "XLS",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9baa7c88-3950-4099-8498-99a4640b95e7",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "application/vnd.ms-excel"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "XLSX",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b83e540c-ba1e-42d0-ac83-f675e25e6aea",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "ELSE",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ea3be820-2ead-4ec2-b292-42d3c7804b55",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.mime_type }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "5b041f53-7f35-4da5-94d0-353aff253cb6",
      "name": "发送不支持响应",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2380,
        2000
      ],
      "webhookId": "017d267f-4897-4726-bf03-304ef10352bf",
      "parameters": {
        "textBody": "=The File type you provided is unsupported.",
        "operation": "send",
        "phoneNumberId": "677680658761861",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.messages[0].from }}"
      },
      "typeVersion": 1
    },
    {
      "id": "17bc97ca-b892-40c6-8029-69c7b7c23772",
      "name": "发送响应",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        3500,
        1020
      ],
      "webhookId": "23834751-5066-48ba-8e19-549680df2b27",
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "677680658761861",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.messages[0].from }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "LSWzVTg64cAdpkcw",
          "name": "WhatsApp account 3"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "145ff6d0-6836-47e4-9e06-fe1a065b83a3",
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "Map image prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map JSON": {
      "main": [
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Types": {
      "main": [
        [
          {
            "node": "Map text prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gets WhatsApp Voicemail Source URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gets WhatsApp Image Source URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gets WhatsApp Document Source URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map text prompt": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Document Chunker": {
      "ai_textSplitter": [
        [
          {
            "node": "Document Section Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XLS": {
      "main": [
        [
          {
            "node": "Map JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map image prompt": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Route Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Document": {
      "main": [
        [
          {
            "node": "Map file extensions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "MongoDB Vector Search",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XLSX": {
      "main": [
        [
          {
            "node": "Map JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Download Voicemail": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map document prompt": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map file extensions": {
      "main": [
        [
          {
            "node": "Route Document Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Docs Importer": {
      "main": [
        [
          {
            "node": "MongoDB Vector Store Inserter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base Agent": {
      "main": [
        [
          {
            "node": "Send Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Document Types": {
      "main": [
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Map document prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Map JSON",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from XLS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from XLSX",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Unsupported Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MongoDB Vector Search": {
      "ai_tool": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Document Section Loader": {
      "ai_document": [
        [
          {
            "node": "MongoDB Vector Store Inserter",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings Generator": {
      "ai_embedding": [
        [
          {
            "node": "MongoDB Vector Store Inserter",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Gets WhatsApp Image Source URL": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "Google Docs Importer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gets WhatsApp Document Source URL": {
      "main": [
        [
          {
            "node": "Download Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gets WhatsApp Voicemail Source URL": {
      "main": [
        [
          {
            "node": "Download Voicemail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客服机器人, AI RAG 检索增强

需要付费吗?

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

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

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

作者
外部链接
在 n8n.io 查看

分享此工作流