{
  "name": "n8n-RAG-Onboarding-Flujo-1",
  "nodes": [
    {
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        },
        "clearStore": true
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.3,
      "position": [
        800,
        48
      ],
      "id": "eec33e10-7de3-4bfd-ac28-dfd9f65e7c44",
      "name": "Simple Vector Store"
    },
    {
      "parameters": {
        "modelName": "embed-multilingual-v3.0"
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "typeVersion": 1,
      "position": [
        768,
        272
      ],
      "id": "e9d1603c-bfe3-4615-a92c-f69b54fa5ee0",
      "name": "Embeddings Cohere",
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        992,
        272
      ],
      "id": "b94e9604-b7d1-4615-b2fe-26d29543ff5c",
      "name": "Default Data Loader"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -208,
        48
      ],
      "id": "8da2d864-a8e2-4345-810f-3783d4e92c4c",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "url": "https://api.github.com/repos/EstebanMoralesV/RAG-Onboarding-de-Desarrolladores/contents/data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        0,
        48
      ],
      "id": "583d36cf-7ced-4806-a314-80a91e07eb93",
      "name": "Listar archivos"
    },
    {
      "parameters": {
        "url": "={{ $json.download_url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        240,
        48
      ],
      "id": "3b742827-7e68-46a5-8e45-51221beb3437",
      "name": "Texto plano"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// 1. OBTENER EL TEXTO DE ENTRADA\n\nlet text = $input.item.json.data || \n           $input.item.json.body || \n           $input.item.json.pageContent || \n           $input.item.json;\n\nif (typeof text !== 'string') {\n  text = JSON.stringify(text);\n}\n\n// 2. RUTINA DE LIMPIEZA DE CONTENIDO\n\n// A. Eliminar encabezado y pie corporativo/acad\u00e9mico (espec\u00edfico para evitar borrar el centro)\ntext = text.replace(/# \ud83c\udfac Fictional Entertainment MX[\\s\\S]*?\\*Plataforma de Streaming[^\\n]*/gi, '');\ntext = text.replace(/# \ud83c\udfac Fictional Entertainment MX[\\s\\S]*?\\*Fictional Entertainment MX es una empresa ficticia\\.\\*/gi, '');\ntext = text.replace(/\\n\\*Plataforma de Streaming \u2022 Microservicios \u2022 Cloud Native \u2022 Seguridad\\*\\n\\n/gi, '');\n\n// B. Eliminar frases sueltas repetitivas\ntext = text.replace(/\u2014 Fictional Entertainment MX/gi, '');\ntext = text.replace(/Documento generado con fines acad\u00e9micos/gi, '');\n\n// C. Eliminar im\u00e1genes en formato Markdown: ![Descripci\u00f3n](https://link...)\ntext = text.replace(/!\\[.*?\\]\\(.*?\\)/g, '');\n\n// D. Eliminar cualquier etiqueta HTML (<div align=\"center\">, <br>, </div>, etc.)\ntext = text.replace(/<[^>]+>/g, '');\n\n// E. Eliminar emojis y pictogramas Unicode\ntext = text.replace(/[\\p{Extended_Pictographic}\\p{Emoji_Presentation}]/gu, '');\n\n// F. Eliminar l\u00edneas divisorias o decorativas (---, ===, ***, !!!)\ntext = text.replace(/^[!\\-*_=]{3,}\\s*$/gm, '');\n\n// G. Limpiar espacios en blanco al inicio y al final de cada l\u00ednea\ntext = text.split('\\n').map(line => line.trim()).join('\\n');\n\n// H. Reducir m\u00faltiples saltos de l\u00ednea (3 o m\u00e1s) a un m\u00e1ximo de 2\ntext = text.replace(/\\n{3,}/g, '\\n\\n');\n\n// I. Limpiar espacios en los extremos globales\ntext = text.trim();\n\n// DEVOLVER EL FORMATO CORRECTO PARA n8n\n\nreturn {\n  json: {\n    pageContent: text\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        464,
        48
      ],
      "id": "dbaf72c7-dd6e-44e7-a409-b3e4e959353c",
      "name": "Preprocesamiento"
    }
  ],
  "connections": {
    "Embeddings Cohere": {
      "ai_embedding": [
        [
          {
            "node": "Simple Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Simple Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Listar archivos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Listar archivos": {
      "main": [
        [
          {
            "node": "Texto plano",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Texto plano": {
      "main": [
        [
          {
            "node": "Preprocesamiento",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preprocesamiento": {
      "main": [
        [
          {
            "node": "Simple Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "9fd01754-7f4f-4750-a941-157494e681d8",
  "nodeGroups": [],
  "id": "Mp2WUoVA7x1SDzCI",
  "tags": []
}