AutomationFlowsAI & RAG › Run a RAG Support Copilot with Claude Sonnet and Openai Embeddings

Run a RAG Support Copilot with Claude Sonnet and Openai Embeddings

BySwapnil Mandloi @swapnil-mandloi on n8n.io

This template ingests internal docs into an in-memory vector knowledge base using OpenAI embeddings, then runs a public support chat powered by Anthropic Claude that answers only from that knowledge and escalates unanswered requests to a Gmail inbox while logging all Q&A to an…

Event trigger★★★★☆ complexityAI-powered16 nodesForm TriggerIn-Memory Vector StoreOpenAI EmbeddingsDocument Default Data LoaderText Splitter Recursive Character Text SplitterChat TriggerAgentAnthropic Chat
AI & RAG Trigger: Event Nodes: 16 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #17557 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "QKpqGFRXPIXe11lI",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "AI Support Copilot (RAG) \u2014 Knowledge-Grounded Agent with Auto-Escalation",
  "tags": [],
  "nodes": [
    {
      "id": "b8877fd6-6856-4c2d-9cad-9d6de0893537",
      "name": "Knowledge Ingest Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Add to knowledge base",
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "Added to the knowledge base. The agent can now answer from it."
            }
          }
        },
        "formTitle": "Add to Knowledge Base",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Source Title",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Knowledge Content",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Paste FAQ, policy, or product docs. The AI support agent will answer from this."
      },
      "typeVersion": 2.6
    },
    {
      "id": "9b91e1e7-905d-4c8b-9fc9-56bad24c54a0",
      "name": "Company Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        288,
        0
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "company_kb",
          "cachedResultName": "company_kb"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e841d15c-8cc4-4694-860d-c1e33cb547f6",
      "name": "Ingest Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        240,
        208
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7d32c792-aec2-4d35-bb79-0cbd980cad51",
      "name": "Document Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        432,
        208
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "source",
                "value": "={{ $(\"Knowledge Ingest Form\").item.json[\"Source Title\"] }}"
              }
            ]
          }
        },
        "jsonData": "={{ $(\"Knowledge Ingest Form\").item.json[\"Knowledge Content\"] }}",
        "jsonMode": "expressionData",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2ebad2f8-8cb9-4256-be4c-b5b08323ace4",
      "name": "Chunk Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        432,
        384
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "bb9de393-3b9f-4cac-9c73-c25b2e66af11",
      "name": "Support Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        608
      ],
      "parameters": {
        "public": true,
        "options": {},
        "initialMessages": "Hi! I am your support assistant. Ask me anything about our product or policies."
      },
      "typeVersion": 1.4
    },
    {
      "id": "cd01adb0-9cf2-44a6-84e6-3eb90fcd371f",
      "name": "AI Support Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        288,
        608
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a customer support assistant for this business. RULES: (1) Always call the \"Knowledge Base Search\" tool first and answer ONLY from what it returns. (2) If the knowledge base does not contain the answer, do NOT guess \u2014 tell the customer you are connecting them with a human, and call the \"Escalate to Human\" tool with the question and context. (3) Also escalate if the customer explicitly asks for a human or seems upset. (4) Keep answers concise, friendly, and accurate. Never invent prices, policies, dates, or commitments."
        }
      },
      "typeVersion": 3.1
    },
    {
      "id": "39bc5d1c-6e17-41ea-a47c-ad499e370a65",
      "name": "Claude Sonnet 4.6",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        192,
        832
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-6",
          "cachedResultName": "Claude Sonnet 4.6"
        },
        "options": {
          "temperature": 0.2,
          "maxTokensToSample": 1024
        }
      },
      "typeVersion": 1.5
    },
    {
      "id": "70e3aec2-cd2f-41a5-8c18-01b56490bc6d",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        320,
        832
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.4
    },
    {
      "id": "ff7528d1-6df3-4b5b-bfb2-cb721038bf94",
      "name": "Knowledge Base Search",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        464,
        832
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "company_kb",
          "cachedResultName": "company_kb"
        },
        "toolDescription": "Search the company knowledge base (FAQs, policies, product docs) to answer the customer question. Always use this before answering."
      },
      "typeVersion": 1.3
    },
    {
      "id": "bc0db381-c923-417b-bc4c-b17b1626362c",
      "name": "Retrieve Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        464,
        1008
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8864a04-ac78-42d5-b3d7-f6176d3cc4c2",
      "name": "Escalate to Human",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        752,
        832
      ],
      "parameters": {
        "sendTo": "<__PLACEHOLDER_VALUE__Your support inbox, e.g. support@company.com__>",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('body', 'The customer question and any relevant context, formatted as clean HTML') }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('subject', 'A short subject line summarizing the escalation') }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b9caeaec-2e15-460b-9417-c41c30156327",
      "name": "Log Q&A",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        560,
        608
      ],
      "parameters": {
        "columns": {
          "value": {
            "answer": "={{ $json.output }}",
            "question": "={{ $(\"Support Chat\").item.json.chatInput }}",
            "logged_at": "={{ $now.toISO() }}",
            "session_id": "={{ $(\"Support Chat\").item.json.sessionId }}"
          },
          "schema": [
            {
              "id": "session_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "session_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "question",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "question",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "answer",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "answer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "logged_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "logged_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow"
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "support_chat_log"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "0d3d2f70-e554-4357-8167-b311358aaf55",
      "name": "Sticky Note c6955ad5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 904,
        "height": 284,
        "content": "## \ud83d\udcda FLOW A \u2014 Knowledge Base Ingestion\n\nPaste your FAQs, policies, and product docs into the form. They are split into chunks, embedded with **OpenAI**, and stored in an in-memory vector store under the shared key `company_kb`.\n\n\u25b6\ufe0f Run this whenever your docs change.\n\ud83d\udca1 Swap the textarea for a file-upload field to ingest PDFs / DOCX."
      },
      "typeVersion": 1
    },
    {
      "id": "05ae4367-5aa1-4829-91f8-972b5bc5a2ad",
      "name": "Sticky Note c9724c04",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        656
      ],
      "parameters": {
        "color": 4,
        "width": 1084,
        "height": 384,
        "content": "## \ud83e\udd16 FLOW B \u2014 RAG Support Agent\n\nA hosted chat where customers ask questions. The agent:\n\u2022  \ud83d\udd0d Searches the **same** `company_kb` via the *Knowledge Base Search* tool\n\u2022  \u2705 Answers ONLY from retrieved docs \u2014 no hallucinations\n\u2022  \ud83e\udde0 Remembers the last 10 turns (Conversation Memory)\n\u2022  \ud83d\udce7 Escalates to a human by email when it can't answer or the customer asks\n\u2022  \ud83d\uddc2\ufe0f Logs every Q&A to the `support_chat_log` table\n\n**Brain:** Claude Sonnet (reasoning) + OpenAI embeddings (retrieval). Set your escalation inbox on *Escalate to Human*.\n\nWorks for any business: SaaS, e-commerce, clinics, agencies, education."
      },
      "typeVersion": 1
    },
    {
      "id": "e3fb608e-edbe-4d1d-9d68-358293f43aa0",
      "name": "Sticky Note 9b731803",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 1196,
        "height": 372,
        "content": "# \ud83e\udd16 AI Support Copilot (RAG) \u2014 Claude Sonnet + OpenAI Embeddings\n\nA knowledge-grounded support agent. **Flow A** ingests your docs; **Flow B** lets customers chat with an agent that answers ONLY from your knowledge base, remembers context, and escalates to a human when it can't answer.\n\n**\u2699\ufe0f Setup (5 min):**  1. Connect credentials \u2014 **Anthropic** (agent) \u00b7 **OpenAI** (embeddings) \u00b7 **Gmail** (escalation).   2. Set your support inbox on the *Escalate to Human* node.   3. Run Flow A once with your FAQs/policies, then activate Flow B and open the chat.\n\n**\ud83d\udccb Requires:** n8n Data Table feature \u00b7 Anthropic API key \u00b7 OpenAI API key \u00b7 Gmail OAuth2.\n\n\u26a0\ufe0f The in-memory vector store resets on restart \u2014 swap for Pinecone / Qdrant for production."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "33e8fea1-93ce-4fc5-8bde-f8be221b3453",
  "nodeGroups": [],
  "connections": {
    "Support Chat": {
      "main": [
        [
          {
            "node": "AI Support Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chunk Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Document Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Document Loader": {
      "ai_document": [
        [
          {
            "node": "Company Knowledge Base",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "AI Support Agent": {
      "main": [
        [
          {
            "node": "Log Q&A",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sonnet 4.6": {
      "ai_languageModel": [
        [
          {
            "node": "AI Support Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Escalate to Human": {
      "ai_tool": [
        [
          {
            "node": "AI Support Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Ingest Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Company Knowledge Base",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Support Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Knowledge Base Search",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base Search": {
      "ai_tool": [
        [
          {
            "node": "AI Support Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Ingest Form": {
      "main": [
        [
          {
            "node": "Company Knowledge Base",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This template ingests internal docs into an in-memory vector knowledge base using OpenAI embeddings, then runs a public support chat powered by Anthropic Claude that answers only from that knowledge and escalates unanswered requests to a Gmail inbox while logging all Q&A to an…

Source: https://n8n.io/workflows/17557/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

A lightweight, self-hosted AI assistant built entirely in n8n. Multi-channel messaging (Telegram, WhatsApp, Gmail), persistent memory, task management, and autonomous work — all in a single visual wor

Telegram Trigger, OpenRouter Chat, Data Table +20
AI & RAG

Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.

Gmail Tool, Google Calendar Tool, Gmail +24
AI & RAG

This workflow ingests onboarding documents from Google Drive into an in-memory vector store with Google Gemini embeddings, then runs a multi-channel onboarding chatbot powered by Groq, sends role-base

Google Drive, In-Memory Vector Store, Google Gemini Embeddings +14
AI & RAG

Chat with docs - 5minAI New version. Uses httpRequest, documentDefaultDataLoader, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi. Event-driven trigger; 62 nodes.

HTTP Request, Document Default Data Loader, Text Splitter Recursive Character Text Splitter +10
AI & RAG

I prepared a detailed guide that illustrates the entire process of building an AI agent using Supabase and Google Drive within N8N workflows.

HTTP Request, Document Default Data Loader, Text Splitter Recursive Character Text Splitter +10