{
  "name": "Build a RAG system with automatic citations using Qdrant, Gemini & OpenAI",
  "nodes": [
    {
      "id": "65d3e882-ef84-4b3b-88b0-bb69bbe6886f",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -400,
        220
      ]
    },
    {
      "id": "db531b5a-588a-4982-aa00-e565d6f5610b",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        940,
        480
      ]
    },
    {
      "id": "5a1606d8-d851-4fb1-a18a-a45f5de3adf2",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1080,
        480
      ]
    },
    {
      "id": "9923f6be-c2a5-4498-9fd2-0ed74ccdab35",
      "name": "Qdrant Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        1000,
        240
      ]
    },
    {
      "id": "db1f5e71-28ef-427e-8911-275ddea4e44f",
      "name": "Create collection",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -180,
        -140
      ]
    },
    {
      "id": "e0936863-4ece-429c-bf32-49f75b5c8bf0",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1060,
        660
      ]
    },
    {
      "id": "1311350d-75d3-4edc-8fa9-584a1c36da6d",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        420,
        220
      ]
    },
    {
      "id": "1f9b623c-4e93-44da-8c9d-cfe9f5d5be9a",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1380,
        240
      ]
    },
    {
      "id": "22aacdc0-8ec5-42e2-b9a0-fb9e5a4aa23c",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -460,
        1080
      ]
    },
    {
      "id": "1e132fba-00a5-414a-8f37-f34645f668ff",
      "name": "Question and Answer Chain",
      "type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
      "position": [
        120,
        1280
      ]
    },
    {
      "id": "badee75e-bca7-49e4-9095-c098cb7adcab",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        0,
        1500
      ]
    },
    {
      "id": "ad8cec62-ce1d-4e58-8e40-9a7a9f4f93c7",
      "name": "Vector Store Retriever",
      "type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
      "position": [
        160,
        1500
      ]
    },
    {
      "id": "0c7d1804-4525-4117-a19d-f2d59195fd47",
      "name": "Qdrant Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        40,
        1680
      ]
    },
    {
      "id": "6cfe7e8a-e593-4e4e-a0be-3379dd85c748",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        20,
        1880
      ]
    },
    {
      "id": "d9aa08b5-ed04-4506-9a2e-f994d4694f48",
      "name": "Embeddings OpenAI4",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        100,
        1140
      ]
    },
    {
      "id": "d0d32470-b1df-40ec-aac1-32e4c9cf2e4e",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        640,
        1140
      ]
    },
    {
      "id": "2edbca72-220e-45a6-8295-830d58611549",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        460,
        940
      ]
    },
    {
      "id": "8d116bc2-73d8-4349-8b4e-8dc0aef7cfa3",
      "name": "Clear collection",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -140,
        220
      ]
    },
    {
      "id": "0d4d3bab-2370-4ced-8f5d-2977d360f72b",
      "name": "Get folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        120,
        220
      ]
    },
    {
      "id": "e81ee92f-db50-4c62-aac7-7bc03e63cc1a",
      "name": "Get file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        700,
        240
      ]
    },
    {
      "id": "c9bdc00a-ca8c-4457-8720-e6dce07e6b22",
      "name": "chatInput",
      "type": "n8n-nodes-base.set",
      "position": [
        -200,
        1080
      ]
    },
    {
      "id": "b65ca747-e738-4b7a-ae02-83840ce0a460",
      "name": "Retrive sources",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        140,
        940
      ]
    },
    {
      "id": "265e2613-0155-4585-8d5c-fcda26975585",
      "name": "Output",
      "type": "n8n-nodes-base.set",
      "position": [
        1060,
        1140
      ]
    },
    {
      "id": "9407fcaf-d90a-46bd-9b1f-b0493a0357c1",
      "name": "Response",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        1140
      ]
    },
    {
      "id": "0b8a715f-36eb-49fd-895e-e8e76fdbb0c1",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -520
      ],
      "parameters": {
        "width": 840,
        "height": 220,
        "content": "## Complete RAG System with Automatic Source Citations Using Qdrant\n\nThis workflow implements a **Retrieval-Augmented Generation (RAG)** system that:\n\n* Stores vectorized documents in **Qdrant**,\n* Re"
      }
    },
    {
      "id": "3220c323-a3d6-4855-ad05-2aaf8761771e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -200
      ],
      "parameters": {
        "width": 880,
        "height": 220,
        "content": "# STEP 1\n\n## Create Qdrant Collection\nChange:\n- QDRANTURL\n- COLLECTION"
      }
    },
    {
      "id": "738835a3-888b-426e-a897-8ddc630b85bf",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        120
      ],
      "parameters": {
        "width": 620,
        "height": 520,
        "content": "# STEP 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Documents vectorization with Qdrant and Google Drive\nChange:\n- QDRANTURL\n- COLLECTION"
      }
    },
    {
      "id": "70205511-2c4a-4f2f-8f68-97e3ede28851",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        620
      ],
      "parameters": {
        "width": 520,
        "height": 420,
        "content": "Set as metadata:\n- FILE_ID from Google Drive\n- FILE_NAME from Google Drive\n\n```\n{\n  \"source\": \"blob\",\n  \"blobType\": \"text/plain\",\n  \"loc\": {\n    \"lines\": {\n      \"from\": 1,\n      \"to\": 15\n    }\n  },\n "
      }
    },
    {
      "id": "921497ff-1beb-4bd1-aecd-81b68c5a0357",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        1400
      ],
      "parameters": {
        "width": 520,
        "height": 200,
        "content": "The final output is:\n\n\nRESPONSE\n\nSources: [\"FILENAME 1\", \"FILENAME 2\",...]\n\n"
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get file": {
      "main": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Response": {
      "main": [
        [
          {
            "node": "Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "chatInput": {
      "main": [
        [
          {
            "node": "Question and Answer Chain",
            "type": "main",
            "index": 0
          },
          {
            "node": "Retrive sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get folder": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrive sources": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clear collection": {
      "main": [
        [
          {
            "node": "Get folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI4": {
      "ai_embedding": [
        [
          {
            "node": "Retrive sources",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store1": {
      "ai_vectorStore": [
        [
          {
            "node": "Vector Store Retriever",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Vector Store Retriever": {
      "ai_retriever": [
        [
          {
            "node": "Question and Answer Chain",
            "type": "ai_retriever",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Question and Answer Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Question and Answer Chain": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "chatInput",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Clear collection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}