{
  "name": "Starter - RAG document intake",
  "nodes": [
    {
      "parameters": {
        "content": "# RAG document intake starter\n\nThis workflow shows the safe shape of a document ingestion flow: load text, split into chunks, add metadata, then replace placeholders with embeddings and vector database nodes.\n\nDo not connect private documents to external model APIs until you confirm data policy and credentials.",
        "height": 290,
        "width": 440
      },
      "id": "rag-note-2026",
      "name": "Read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -780,
        -210
      ]
    },
    {
      "parameters": {},
      "id": "rag-manual-trigger-2026",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -780,
        170
      ]
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      document_id: 'doc-001',\n      title: 'Refund policy FAQ',\n      source_url: 'https://example.com/refund-policy',\n      text: 'Customers can request a refund within 7 days. Enterprise contracts may follow a separate agreement. Support should check the order ID before approving a refund.',\n      imported_at: new Date().toISOString()\n    }\n  }\n];"
      },
      "id": "rag-sample-document-2026",
      "name": "Sample document",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -520,
        170
      ]
    },
    {
      "parameters": {
        "jsCode": "const chunkSize = 180;\nconst overlap = 30;\nconst output = [];\n\nfor (const item of items) {\n  const doc = item.json;\n  const text = String(doc.text || '').trim();\n  let index = 0;\n  let chunkIndex = 0;\n\n  while (index < text.length) {\n    const chunk = text.slice(index, index + chunkSize).trim();\n    if (chunk) {\n      output.push({\n        json: {\n          document_id: doc.document_id,\n          title: doc.title,\n          source_url: doc.source_url,\n          chunk_id: `${doc.document_id}-${chunkIndex + 1}`,\n          chunk_index: chunkIndex,\n          chunk_text: chunk,\n          metadata: {\n            imported_at: doc.imported_at,\n            source_type: 'starter_template'\n          }\n        }\n      });\n    }\n\n    chunkIndex += 1;\n    index += Math.max(chunkSize - overlap, 1);\n  }\n}\n\nreturn output;"
      },
      "id": "rag-chunk-document-2026",
      "name": "Chunk document",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -260,
        170
      ]
    },
    {
      "parameters": {},
      "id": "rag-embedding-placeholder-2026",
      "name": "Replace with embeddings",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        20,
        170
      ]
    },
    {
      "parameters": {},
      "id": "rag-vector-placeholder-2026",
      "name": "Replace with vector database",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        300,
        170
      ]
    },
    {
      "parameters": {},
      "id": "rag-log-placeholder-2026",
      "name": "Replace with import log",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        580,
        170
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Sample document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample document": {
      "main": [
        [
          {
            "node": "Chunk document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chunk document": {
      "main": [
        [
          {
            "node": "Replace with embeddings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace with embeddings": {
      "main": [
        [
          {
            "node": "Replace with vector database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace with vector database": {
      "main": [
        [
          {
            "node": "Replace with import log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "tags": []
}
