AutomationFlowsAI & RAG › RAG Chat with OpenAI Embeddings

RAG Chat with OpenAI Embeddings

Original n8n title: [lab] N8n RAG in Memory Vector

[Lab] n8n RAG in memory vector. Uses formTrigger, embeddingsOpenAi, documentDefaultDataLoader, vectorStoreInMemory. Event-driven trigger; 12 nodes.

Event trigger★★★☆☆ complexityAI-powered12 nodesForm TriggerOpenAI EmbeddingsDocument Default Data LoaderIn-Memory Vector StoreAgentChat TriggerOpenAI Chat
AI & RAG Trigger: Event Nodes: 12 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #rag-starter-template — 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
{
  "name": "[Lab] n8n RAG in memory vector",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Upload your data to test RAG",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Upload your file(s)",
              "fieldType": "file",
              "acceptFileTypes": ".pdf, .csv",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        -128,
        0
      ],
      "id": "f7a656ec-83fc-4ed2-a089-57a9def662b7",
      "name": "Upload your file here"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        528,
        480
      ],
      "id": "6ea78663-cf2f-4f2d-8e68-43047c2afd87",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "dataType": "binary",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        320,
        160
      ],
      "id": "94aecac0-03f9-4915-932b-d14a2576607b",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "content": "### Readme\uff08\u7e41\u9ad4\u4e2d\u6587\uff09\n\n\u4f7f\u7528 \ud83d\udcda **\u8b80\u53d6\u8cc7\u6599** \u6d41\u7a0b\u5c07\u8cc7\u6599\u8f09\u5165\u5411\u91cf\u8cc7\u6599\u5eab\uff0c\u63a5\u8457\u4f7f\u7528 \ud83d\udc15 **Retriever** \u6d41\u7a0b\uff0c\u5c07\u4f60\u7684\u8cc7\u6599\u4f5c\u70ba\u804a\u5929\u7684\u4e0a\u4e0b\u6587\u3002\n\n**\u5feb\u901f\u958b\u59cb**\n\n1. \u9ede\u64ca `Execute Workflow` \u6309\u9215\u4ee5\u57f7\u884c \ud83d\udcda **\u8b80\u53d6\u8cc7\u6599** \u6d41\u7a0b\u3002\n2. \u9ede\u64ca `Open Chat` \u6309\u9215\u4ee5\u57f7\u884c \ud83d\udc15 **\u6aa2\u7d22** \u6d41\u7a0b\uff0c\u7136\u5f8c\u91dd\u5c0d\u4f60\u7684\u6587\u4ef6\u5167\u5bb9\u63d0\u51fa\u554f\u984c\u3002\n\n\u66f4\u591a\u8cc7\u8a0a\u8acb\u53c3\u8003 [n8n \u4e2d\u7684 RAG \u6587\u4ef6](https://docs.n8n.io/advanced-ai/rag-in-n8n/)\u3002 \u2705\n\n\n",
        "height": 300,
        "width": 440,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -64
      ],
      "typeVersion": 1,
      "id": "0d07742b-0b36-4c2e-990c-266cbe6e2d4d",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "### \ud83d\udcda \u8b80\u53d6\u8cc7\u6599",
        "height": 460,
        "width": 700,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -64
      ],
      "typeVersion": 1,
      "id": "d19d04f3-5231-4e47-bed7-9f24a4a8f582",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "value": "vector_store_key",
          "mode": "list",
          "cachedResultName": "vector_store_key"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.2,
      "position": [
        64,
        0
      ],
      "id": "bf50a11f-ca6a-4e04-a6d2-42fee272b260",
      "name": "Insert Data to Store"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "knowledge_base",
        "toolDescription": "Use this knowledge base to answer questions from the user",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.2,
      "position": [
        944,
        208
      ],
      "id": "09c0db62-5413-440e-8c13-fb6bb66d9b6a",
      "name": "Query Data Tool"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        944,
        -32
      ],
      "id": "579aed76-9644-42d1-ac13-7369059ff1c2",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        720,
        -16
      ],
      "id": "9c30de61-935a-471f-ae88-ec5f67beeefc",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        720,
        208
      ],
      "id": "b5aa8942-9cd5-4c2f-bd77-7a0ceb921bac",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "### \ud83d\udc15 2. \u6aa2\u7d22",
        "height": 460,
        "width": 680,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -64
      ],
      "typeVersion": 1,
      "id": "28bc73a1-e64a-47bf-ac1c-ffe644894ea5",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "### \u5411\u91cf\u5d4c\u5165\uff08Embeddings\uff09\n\n\u63d2\u5165\uff08Insert\uff09\u8207\u6aa2\u7d22\uff08Retrieve\uff09\u64cd\u4f5c\u6703\u4f7f\u7528\u76f8\u540c\u7684\u5d4c\u5165\u7bc0\u9ede\u3002\n\n\u9019\u662f\u70ba\u4e86\u78ba\u4fdd\u5b83\u5011\u4f7f\u7528 **\u5b8c\u5168\u76f8\u540c\u7684\u5d4c\u5165\u8207\u8a2d\u5b9a**\u3002\n\n\u82e5\u4f7f\u7528\u4e0d\u540c\u7684\u5d4c\u5165\uff0c\u53ef\u80fd\u6703\u5b8c\u5168\u7121\u6cd5\u904b\u4f5c\uff0c\u6216\u7522\u751f\u975e\u9810\u671f\u7684\u7d50\u679c\u3002 \u2705\n",
        "height": 240,
        "width": 320,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        448
      ],
      "typeVersion": 1,
      "id": "0cf8c647-418c-4d1a-8952-766145afca72",
      "name": "Sticky Note3"
    }
  ],
  "connections": {
    "Upload your file here": {
      "main": [
        [
          {
            "node": "Insert Data to Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Insert Data to Store",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Query Data Tool",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Insert Data to Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Query Data Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "58ce0d64-f31e-4a07-ae68-387180d5d193",
  "meta": {
    "templateId": "rag-starter-template"
  },
  "id": "68ALT8wDIIIu8Wch",
  "tags": [
    {
      "createdAt": "2025-01-21T07:13:32.979Z",
      "updatedAt": "2025-01-21T07:13:32.979Z",
      "id": "UgFtmn8Gj5krewbJ",
      "name": "RAG"
    }
  ]
}

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

[Lab] n8n RAG in memory vector. Uses formTrigger, embeddingsOpenAi, documentDefaultDataLoader, vectorStoreInMemory. Event-driven trigger; 12 nodes.

Source: https://github.com/qwedsazxc78/ai-automation-n8n/blob/bc074b119e8c8f42b3ceaf6f05d016d893869008/n8n/47-rag-n8n-notebooklm/rag-agent-memory.json — 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

This workflow implements a complete Retrieval-Augmented Generation (RAG) knowledge assistant with built-in document ingestion, conversational AI, and automated analytics using n8n, OpenAI, and Pinecon

Form Trigger, Data Table, Text Splitter Recursive Character Text Splitter +8
AI & RAG

This is a template for n8n's evaluation feature.

Evaluation Trigger, Evaluation, Chat Trigger +8
AI & RAG

The scoring approach is adapted from https://cloud.google.com/vertex-ai/generative-ai/docs/models/metrics-templates#pointwise_groundedness This evaluation works best for an agent that requires documen

HTTP Request, In-Memory Vector Store, OpenAI Embeddings +9
AI & RAG

An upgraded Retrieval-Augmented Generation (RAG) chatbot built in n8n that lets users ask questions via Telegram and receive accurate answers from uploaded PDFs. It embeds documents using OpenAI and b

OpenAI Embeddings, Document Default Data Loader, In-Memory Vector Store +6
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

In-Memory Vector Store, Agent, Chat Trigger +6