{
  "name": "RAG_Ingest",
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.mistral.ai/v1/files",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "purpose",
              "value": "ocr"
            },
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1984,
        1072
      ],
      "id": "56ca873a-cb23-4839-ae45-18dfcb170314",
      "name": "HTTP Request-Upload file to Mistral",
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://api.mistral.ai/v1/files/{{ $json.id }}/url",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "expiry",
              "value": "24"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1760,
        1072
      ],
      "id": "61d458e6-6b2e-4e5a-89b4-e38638a26e3e",
      "name": "HTTP Request Get signed URL",
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.mistral.ai/v1/ocr",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"document_url\",\n    \"document_url\": \"{{ $json.url }}\"\n  },\n  \"include_image_base64\": true,\n  \"bbox_annotation_format\": {\n    \"type\": \"json_schema\",\n    \"json_schema\": {\n      \"schema\": {\n        \"properties\": {\n          \"document_type\": {\n            \"title\": \"Document_Type\",\n            \"description\": \"The type of the image.\",\n            \"type\": \"string\"\n          },\n          \"short_description\": {\n            \"title\": \"Short_Description\",\n            \"description\": \"A description in English describing the image based on the figure description below or above image.\",\n            \"type\": \"string\"\n          }\n        },\n        \"required\": [\"document_type\", \"short_description\"],\n        \"title\": \"BBOXAnnotation\",\n        \"type\": \"object\",\n        \"additionalProperties\": false\n      },\n      \"name\": \"document_annotation\",\n      \"strict\": true\n    }\n  }\n}\n",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1536,
        1072
      ],
      "id": "22815164-8386-4603-bd39-dc61b69f6642",
      "name": "HTTP Request Image BBox Annotation",
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "pages",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -1104,
        1072
      ],
      "id": "98fe5aa6-d8cb-41be-b1fb-78f279496f1f",
      "name": "Split Out - by pages"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// 1) Grab the existing markdown and image list from the current item\nlet markdown = $json.markdown;\nconst images = $json.images || [];\n\n// 2) For each image, build the annotated markdown and replace the plain tag\nfor (const image of images) {\n  // assume image.id is the filename (e.g. \"img-35.jpeg\")\n  const fileName   = image.id;\n  // your OCR/AI result lives in image.image_annotation\n  const annotation = image.image_annotation || '';\n\n  // the original markdown tag\n  const imageMarkdown     = `![${fileName}](${fileName})`;\n  // plus its annotation\n  const annotatedMarkdown = `${imageMarkdown}\\n\\n${annotation}`;\n\n  // do an in-place replacement\n  markdown = markdown.replaceAll(imageMarkdown, annotatedMarkdown);\n}\n\n// 3) Return the full JSON, spreading in any other fields but with updated markdown\nreturn {\n  json: {\n    ...$json,\n    markdown\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -880,
        1072
      ],
      "id": "e8fd558a-1c76-4736-8041-58d6a489ceea",
      "name": "Code"
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "={{ $('Superbase Bucket - Text').item.json.superbase_storage_bucket_name }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.3,
      "position": [
        -640,
        1072
      ],
      "id": "67c2ae80-4d05-43bd-884e-61e205d53f7f",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonMode": "expressionData",
        "jsonData": "={{ $('Code').item.json.markdown }}",
        "textSplittingMode": "custom",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        -496,
        1280
      ],
      "id": "9beba435-3d5e-4bc1-97b1-d8b7a43a9a3b",
      "name": "Default Data Loader1"
    },
    {
      "parameters": {
        "chunkOverlap": 200,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        -416,
        1504
      ],
      "id": "638271db-bb39-4774-8040-3776598da46f",
      "name": "Recursive Character Text Splitter1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        -640,
        1232
      ],
      "id": "a021f796-3b92-42c6-8a61-d77e4bb0faa9",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Text Data Ingestion - VectorStore (Superbase)\n### Connect to any persistant PDF storage (in this case google drive)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
        "height": 1500,
        "width": 3640
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3728,
        368
      ],
      "id": "65768942-83ba-4959-bf25-a7745b9779df",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.mistral.ai/v1/files",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "purpose",
              "value": "ocr"
            },
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1968,
        -448
      ],
      "id": "623a68d8-6381-42cb-b109-41e6e1e217c1",
      "name": "HTTP Request - Upload PDF to Mistral",
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://api.mistral.ai/v1/files/{{ $json.id }}/url ",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "expiry",
              "value": "24"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1744,
        -448
      ],
      "id": "1ce22cec-ed3a-4395-946d-acf112929957",
      "name": "HTTP Request - Get signed URL if uploaded to Mistral",
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "**NOTE**: When uploaded file to Mistral, you need to ask Mistral to generate a pre-signed URl for the file you have uploaded with the **$id** filled out - since the files in the Mistrals storage are private by default - you need to request URL.",
        "height": 140,
        "width": 320,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1968,
        -608
      ],
      "id": "affb5760-0da6-4eff-b2d1-a1f047a7ce5b",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.mistral.ai/v1/ocr",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"document_url\",\n    \"document_url\": \"{{ $json.url }}\"\n  },\n  \"include_image_base64\": true,\n  \"bbox_annotation_format\": {\n    \"type\": \"json_schema\",\n    \"json_schema\": {\n      \"schema\": {\n        \"properties\": {\n          \"document_type\": {\n            \"title\": \"Document_Type\",\n            \"description\": \"The type of the image.\",\n            \"type\": \"string\"\n          },\n          \"short_description\": {\n            \"title\": \"Short_Description\",\n            \"description\": \"A description in English describing the image based on the figure description below or above image.\",\n            \"type\": \"string\"\n          }\n        },\n        \"required\": [\"document_type\", \"short_description\"],\n        \"title\": \"BBOXAnnotation\",\n        \"type\": \"object\",\n        \"additionalProperties\": false\n      },\n      \"name\": \"document_annotation\",\n      \"strict\": true\n    }\n  }\n}\n",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1520,
        -448
      ],
      "id": "8c5f9a44-31ea-4c78-ac98-6393d75b4a0c",
      "name": "HTTP Request - OCR and Image Annotation",
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "**NOTE**: When uploaded file to Mistral, you need to ask Mistral to generate a pre-signed URl for the file you have uploaded with the **$id** filled out - since the files in the Mistrals storage are private by default - you need to request URL.",
        "height": 140,
        "width": 320,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1984,
        912
      ],
      "id": "48058eb9-6a16-4321-8dd4-110ced0bf63d",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "fieldToSplitOut": "pages",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -1328,
        -624
      ],
      "id": "56be117b-cb90-4fd9-a504-7cb77f22fc72",
      "name": "Split Out - (pages)"
    },
    {
      "parameters": {
        "fieldToSplitOut": "images",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -1104,
        -624
      ],
      "id": "5ad402be-f34d-4430-b6c8-dc2a71e3eeef",
      "name": "Split Out - (images)"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6731d779-aaf6-474d-ba31-01ce46601207",
              "name": "=file_name",
              "value": "={{ \n  (\n    Date.now().toString(36)\n    + Math.random().toString(36).substring(2,10)\n    + Math.random().toString(36).substring(2,10)\n    + Math.random().toString(36).substring(2,10)\n  ).toLowerCase()\n}}",
              "type": "string"
            },
            {
              "id": "374e8312-d304-4a55-bc1a-efcb6a603121",
              "name": "original_id",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "e42e5cc5-aee5-4d84-9a35-c67a6d80dfbe",
              "name": "image_annotation",
              "value": "={{ $json.image_annotation }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -864,
        -624
      ],
      "id": "cd83892e-6a10-44d9-a0b9-371032d10dde",
      "name": "Extract the file name, id, and annotation"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fad321ce-9612-4d43-bdda-47e4bb9fd88e",
              "name": "image_base64",
              "value": "={{ $('Split Out - (images)').item.json.image_base64\n    .split('data:image/jpeg;base64,')[1] }}\n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -640,
        -784
      ],
      "id": "f6936cae-57c0-4ad9-af0b-8f48548fb0f7",
      "name": "Extract image_base64"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "=image_base64",
        "options": {
          "fileName": "={{ $('Extract the file name, id, and annotation').item.json.file_name }}"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -416,
        -784
      ],
      "id": "01b75083-b11d-40bc-834a-ec03b5ddc501",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "content": "### **NOTE:**  for \"Upload base64 strings to superbase storage\"\n\nWhenever you want to hit Supabase Storage via HTTP, you use your project\u2019s base URL (the same one you see in your Dashboard) plus the Storage REST path. Concretely:\n\n{project_ref}/storage/v1/object/{bucket}/{your-path-and-filename.ext}\n\n- {project_ref} \u2013 found in your Dashboard under Settings \u2192 API \u2192 Project URL\n\n- {bucket} \u2013 the name of the Storage bucket you created (e.g. avatars)\n\n- {your-path-and-filename.ext} \u2013 where you want it saved, e.g. uploads/user123.png - in my case due to aggregation later I used {{ $binary.data.fileName }} - to match the binary file name.\n\n- If you open the Supabase docs for Upload a new object, you\u2019ll see exactly that endpoint listed (and examples in cURL, JS, etc.)",
        "height": 280,
        "width": 680,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -608,
        -1088
      ],
      "id": "cbe9dc52-0d81-488f-87bb-b90a03473300",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "688f1256-cfab-491f-b466-d96c09954c76",
              "name": "file_name",
              "value": "={{ $json.Key.split('/').slice(1).join('/') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        32,
        -784
      ],
      "id": "95588fa7-ec69-4a07-992b-77fbe75de792",
      "name": "Get Uploaded Filename"
    },
    {
      "parameters": {
        "mode": "combine",
        "fieldsToMatchString": "file_name",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        240,
        -640
      ],
      "id": "505da9d2-f1a7-4c75-81fc-4f202c61d35a",
      "name": "Merge results"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Superbase Bucket - Image').item.json.superbase_base_url }}/storage/v1/object/{{ $('Superbase Bucket - Image').item.json.superbase_storage_bucket_name }}/{{ $binary.data.fileName }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -208,
        -784
      ],
      "id": "4f35d463-50ad-42d8-9f09-d70be1e2e70f",
      "name": "Upload base64 strings to superbase storage",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "uploaded_images",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        432,
        -640
      ],
      "id": "792587f7-b699-4741-8d59-e44f3f90c794",
      "name": "Aggregate"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        624,
        -464
      ],
      "id": "657f0b75-438a-4990-92ec-8408a4abe101",
      "name": "Merge"
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "queryString": "*",
        "returnAll": true,
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "={{ $json.id }}",
            "mode": "id"
          }
        },
        "options": {}
      },
      "id": "2a392e7e-f7fa-4a3d-964c-3549b329dd6a",
      "name": "Search files and folders",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -2480,
        -448
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "={{ $('Superbase Bucket - Image').item.json.superbase_storage_bucket_name }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.3,
      "position": [
        1392,
        -464
      ],
      "id": "ece29956-0ee6-4388-b8c2-5fb1985db8fc",
      "name": "Supabase Vector Store (image)",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonMode": "expressionData",
        "jsonData": "={{ $json.markdown }}",
        "textSplittingMode": "custom",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        1488,
        -304
      ],
      "id": "837117d8-ac5d-47ca-b491-dabebf9c12f3",
      "name": "Default Data Loader (image)"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        1360,
        -304
      ],
      "id": "3b5f2cd0-352e-408f-839d-5ae9f348322a",
      "name": "Embeddings OpenAI (image)",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chunkSize": 800,
        "chunkOverlap": 200,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        1504,
        -160
      ],
      "id": "a8d8dd0a-980e-4a5a-9a06-af92b8a17609",
      "name": "Recursive Character Text Splitter (image)"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Safely access uploaded_images from Merge1\nconst mergeItems = $items('Merge');\n// const uploadedImages = mergeItems.json.uploaded_images || [];\nconst uploadedImages = mergeItems.flatMap(i => i.json.uploaded_images || []);\n\n// return {\n//   json: {\n//     debug_uploadCount: uploadedImages.length,\n//     debug_mergeItems: mergeItems.map(i => i.json.uploaded_images),\n//   },\n// };\n\nlet markdown = $json.markdown;\nconst supabaseBaseUrl = $('Superbase Bucket - Image').item.json.superbase_base_url;\nconst bucketName = $('Superbase Bucket - Image').item.json.superbase_storage_bucket_name;\nconst fullBaseUrl = `${supabaseBaseUrl}/storage/v1/object/public/${bucketName}/`;\n\n// Only run replacement if uploadedImages is a non-empty array\n// if (uploadedImages.length > 0) {\nfor (const image of uploadedImages) {\n  const originalId = image.original_id;\n  const fileName   = image.file_name;\n   // 1) Normalize the annotation into a JS object (if needed)\n  let annObj = image.image_annotation || \"\";\n  if (typeof annObj === 'string') {\n    try {\n      annObj = JSON.parse(annObj);\n    } catch {\n      // leave it as the raw string if it isn't valid JSON\n    }\n  }\n\n  // 2) Pull out the text you actually want (e.g. short_description)\n  const annotationText =\n    (annObj && annObj.short_description)        // common key\n    || (annObj && annObj.text)                  // alternate key\n    || `${annObj}`                              // fallback to whatever it is\n\n  // 3) Build your regex + replacement exactly as before\n  const re = new RegExp(`!\\\\[${originalId}\\\\]\\\\(${originalId}\\\\)`, 'g');\n  const replacement =\n    `![${originalId}](${fullBaseUrl}${fileName})\\n\\n${annotationText}`;\n\n  markdown = markdown.replace(re, replacement);\n}\n\n\nreturn {\n  json: {\n    ...$json,\n    markdown,\n  },\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1104,
        -464
      ],
      "id": "d71e54ef-e389-4596-ac30-efd682409625",
      "name": "Code (B)"
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/drive/v3/files/{{ $json.folder_id }}?fields=*",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2736,
        -448
      ],
      "id": "8fc7308d-54ca-491d-8e45-92be0c687347",
      "name": "Get File Metadata",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -2224,
        -448
      ],
      "id": "b70d4874-de6e-42b2-8878-1f7508fa73fb",
      "name": "Download Drive File",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Image Data Ingestion - VectorStore (Superbase)\n### Connect to any persistant PDF storage (in this case google drive)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
        "height": 1440,
        "width": 5480,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3728,
        -1120
      ],
      "id": "ee84a971-72ab-43c4-951d-56da594fb54c",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "fieldToSplitOut": "pages",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        864,
        -464
      ],
      "id": "b127feb5-7389-4e84-ac4f-5f024a5c899f",
      "name": "Split Out-pages"
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1RMKBn30Fupnj-cIIC_fR0dN8PXutCKhZ",
          "mode": "list",
          "cachedResultName": "B",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1RMKBn30Fupnj-cIIC_fR0dN8PXutCKhZ"
        },
        "event": "fileUpdated",
        "options": {
          "fileType": "all"
        }
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        528
      ],
      "id": "40a06bed-63f6-427d-9bf2-7c56e887c13e",
      "name": "Google Drive Trigger (B) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1rrFtRwuiiK6Y6WAuSaweGsMgVH-sqjoy",
          "mode": "list",
          "cachedResultName": "C",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1rrFtRwuiiK6Y6WAuSaweGsMgVH-sqjoy"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        704
      ],
      "id": "809ad928-72dd-474f-8b57-77acb1084c6a",
      "name": "Google Drive Trigger (C) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1IRgTR4ahn5DDGuiji3mSL94OTeHEyAui",
          "mode": "list",
          "cachedResultName": "D",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1IRgTR4ahn5DDGuiji3mSL94OTeHEyAui"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        880
      ],
      "id": "8c4b3a4b-b271-4139-bb11-a9437348ecdd",
      "name": "Google Drive Trigger (D) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1OWdxpEEc5d6UzXumaTCuwzdnmBZVQCi2",
          "mode": "list",
          "cachedResultName": "E",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1OWdxpEEc5d6UzXumaTCuwzdnmBZVQCi2"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        1072
      ],
      "id": "9a67396d-9a67-49f6-8cff-c973138c44e4",
      "name": "Google Drive Trigger (E) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1FQJB48L1gyf0CEXgxj0o8kW6IaeMdHBd",
          "mode": "list",
          "cachedResultName": "F",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1FQJB48L1gyf0CEXgxj0o8kW6IaeMdHBd"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        1248
      ],
      "id": "82e426f9-2843-4aae-80c2-fe483cb8868d",
      "name": "Google Drive Trigger (F) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1Q-ND07j0klS1Dz2AhRIUT4rOuJPxcmdk",
          "mode": "list",
          "cachedResultName": "G",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Q-ND07j0klS1Dz2AhRIUT4rOuJPxcmdk"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        1424
      ],
      "id": "28ad656d-6758-4ab7-bca2-1db061fa0f5a",
      "name": "Google Drive Trigger (G) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1EdNbm4tHJO_XeQJ6JRrzAFFm3XezMIT2",
          "mode": "list",
          "cachedResultName": "H",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1EdNbm4tHJO_XeQJ6JRrzAFFm3XezMIT2"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3600,
        1600
      ],
      "id": "5d2403ae-c203-412f-929d-5d07ab3e019e",
      "name": "Google Drive Trigger (H) - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-h",
              "type": "string"
            },
            {
              "id": "8cd7560d-c6cf-477e-97a3-0cab98fc6ccc",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        1600
      ],
      "id": "7b2bb0e1-c3c8-49e6-a6cd-733ed42b6bef",
      "name": "Superbase Bucket (code_h) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-g",
              "type": "string"
            },
            {
              "id": "f5e143db-043e-4da6-9df2-e8493c169398",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        1424
      ],
      "id": "740dc07f-91b2-4352-9459-3467477e7d2b",
      "name": "Superbase Bucket (code_g) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-f",
              "type": "string"
            },
            {
              "id": "db6318eb-b8f6-4737-b88e-a84189e8f04d",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        1248
      ],
      "id": "035b1c0b-be42-4f8a-a015-157d156a099c",
      "name": "Superbase Bucket (code_f) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-e",
              "type": "string"
            },
            {
              "id": "791a3f88-f902-44c1-a764-9e9234e0dd87",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        1072
      ],
      "id": "47cea84d-33a6-4fa0-a20b-887c2c86dbaa",
      "name": "Superbase Bucket (code_e) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-d",
              "type": "string"
            },
            {
              "id": "6d120749-d748-4dba-af49-29ac572c5fe6",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        880
      ],
      "id": "f0877f91-0d6b-471b-b34b-880482ada06d",
      "name": "Superbase Bucket (code_d) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-c",
              "type": "string"
            },
            {
              "id": "2998ce44-55e9-4404-b2aa-6247ce2b378e",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        704
      ],
      "id": "cdd85e31-bc8d-44c7-b807-72b15536bef6",
      "name": "Superbase Bucket (code_c) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-b",
              "type": "string"
            },
            {
              "id": "37323b0e-3c37-4d4e-b74c-dcb56ed198ca",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3328,
        528
      ],
      "id": "4d3a2fc0-c767-4278-8195-4c350e3c3202",
      "name": "Superbase Bucket (code_b) - Text"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "={{ $json.superbase_storage_bucket_name }}",
              "type": "string"
            },
            {
              "id": "6d120749-d748-4dba-af49-29ac572c5fe6",
              "name": "folder_id",
              "value": "={{ $json.folder_id }}",
              "type": "string"
            },
            {
              "id": "b765ed82-2930-47fb-838f-869bfd43f3df",
              "name": "superbase_base_url",
              "value": "={{ $json.superbase_base_url }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3008,
        1072
      ],
      "id": "100de973-0b28-4598-b32a-ff54da94c6cc",
      "name": "Superbase Bucket - Text"
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/drive/v3/files/{{ $json.folder_id }}?fields=*",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2720,
        1072
      ],
      "id": "e20d1ec8-6f30-4968-841d-50756daec5fd",
      "name": "Get File Metadata - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "queryString": "*",
        "returnAll": true,
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "={{ $json.id }}",
            "mode": "id"
          }
        },
        "options": {}
      },
      "id": "47205665-88e2-401e-a876-f6b9ca3da1a4",
      "name": "Search files and folders - Text",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -2464,
        1072
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -2208,
        1072
      ],
      "id": "5ead6472-7e44-4564-8f5b-643f00bb3fb7",
      "name": "Download Drive File - Text",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1RMKBn30Fupnj-cIIC_fR0dN8PXutCKhZ",
          "mode": "list",
          "cachedResultName": "B",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1RMKBn30Fupnj-cIIC_fR0dN8PXutCKhZ"
        },
        "event": "fileUpdated",
        "options": {
          "fileType": "all"
        }
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        -976
      ],
      "id": "1d726d0e-b67c-42ab-8d01-c2eec273eb46",
      "name": "Google Drive Trigger (B) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1rrFtRwuiiK6Y6WAuSaweGsMgVH-sqjoy",
          "mode": "list",
          "cachedResultName": "C",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1rrFtRwuiiK6Y6WAuSaweGsMgVH-sqjoy"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        -800
      ],
      "id": "ae236eef-9414-49fe-a8dd-caed4586509a",
      "name": "Google Drive Trigger (C) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1IRgTR4ahn5DDGuiji3mSL94OTeHEyAui",
          "mode": "list",
          "cachedResultName": "D",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1IRgTR4ahn5DDGuiji3mSL94OTeHEyAui"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        -624
      ],
      "id": "34e1eb1e-3fc6-47dc-a315-72700e074189",
      "name": "Google Drive Trigger (D) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1OWdxpEEc5d6UzXumaTCuwzdnmBZVQCi2",
          "mode": "list",
          "cachedResultName": "E",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1OWdxpEEc5d6UzXumaTCuwzdnmBZVQCi2"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        -448
      ],
      "id": "4c86b224-b48f-4dca-8843-afb292b52fbe",
      "name": "Google Drive Trigger (E) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1FQJB48L1gyf0CEXgxj0o8kW6IaeMdHBd",
          "mode": "list",
          "cachedResultName": "F",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1FQJB48L1gyf0CEXgxj0o8kW6IaeMdHBd"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        -256
      ],
      "id": "78bb0db3-e20d-437e-8240-0654ce6a3730",
      "name": "Google Drive Trigger (F) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1Q-ND07j0klS1Dz2AhRIUT4rOuJPxcmdk",
          "mode": "list",
          "cachedResultName": "G",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Q-ND07j0klS1Dz2AhRIUT4rOuJPxcmdk"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        -80
      ],
      "id": "a0636e73-f442-42fb-90bd-65ba9a11ae99",
      "name": "Google Drive Trigger (G) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1EdNbm4tHJO_XeQJ6JRrzAFFm3XezMIT2",
          "mode": "list",
          "cachedResultName": "H",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1EdNbm4tHJO_XeQJ6JRrzAFFm3XezMIT2"
        },
        "event": "fileUpdated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -3616,
        112
      ],
      "id": "6c4f5e7d-742f-4904-b064-fb11fa1a04c7",
      "name": "Google Drive Trigger (H) - Image",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-b",
              "type": "string"
            },
            {
              "id": "37323b0e-3c37-4d4e-b74c-dcb56ed198ca",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        -976
      ],
      "id": "bc27413d-c8f9-4c2c-bf6b-d10beb5ded7f",
      "name": "Superbase Bucket (code_b) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-c",
              "type": "string"
            },
            {
              "id": "2998ce44-55e9-4404-b2aa-6247ce2b378e",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        -800
      ],
      "id": "2aa67fcd-5f0d-4152-bf50-92480d7c179f",
      "name": "Superbase Bucket (code_c) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-d",
              "type": "string"
            },
            {
              "id": "6d120749-d748-4dba-af49-29ac572c5fe6",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        -624
      ],
      "id": "f6ef704a-d2a0-458c-8667-b67145600253",
      "name": "Superbase Bucket (code_d) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-e",
              "type": "string"
            },
            {
              "id": "791a3f88-f902-44c1-a764-9e9234e0dd87",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        -448
      ],
      "id": "cc968ba0-3621-4644-b850-76a3df531fa6",
      "name": "Superbase Bucket (code_e) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-f",
              "type": "string"
            },
            {
              "id": "db6318eb-b8f6-4737-b88e-a84189e8f04d",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        -256
      ],
      "id": "34175fa0-1dd0-4948-81ae-c850d4db892c",
      "name": "Superbase Bucket (code_f) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-g",
              "type": "string"
            },
            {
              "id": "f5e143db-043e-4da6-9df2-e8493c169398",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        -80
      ],
      "id": "7fc58e18-3203-46ac-aba7-25a3ac41091a",
      "name": "Superbase Bucket (code_g) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1a0c1b9-247a-47a2-8ada-eb34bcb2a6cd",
              "name": "superbase_base_url",
              "value": "https://evxduxdszbxukcjocizl.supabase.co",
              "type": "string"
            },
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "code-h",
              "type": "string"
            },
            {
              "id": "8cd7560d-c6cf-477e-97a3-0cab98fc6ccc",
              "name": "folder_id",
              "value": "={{ $json.parents[0] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        112
      ],
      "id": "694206ed-bfa8-48a7-878a-40b8f7d52c98",
      "name": "Superbase Bucket (code_h) - Image"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a0bbccc7-3be2-4ab9-9d13-0e24a4606d84",
              "name": "superbase_storage_bucket_name",
              "value": "={{ $json.superbase_storage_bucket_name }}",
              "type": "string"
            },
            {
              "id": "6d120749-d748-4dba-af49-29ac572c5fe6",
              "name": "folder_id",
              "value": "={{ $json.folder_id }}",
              "type": "string"
            },
            {
              "id": "b765ed82-2930-47fb-838f-869bfd43f3df",
              "name": "superbase_base_url",
              "value": "={{ $json.superbase_base_url }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3024,
        -448
      ],
      "id": "e5741ec3-46db-42aa-8b85-20437f4ae7a1",
      "name": "Superbase Bucket - Image"
    },
    {
      "parameters": {
        "content": "**NOTE:** Code node is setup so that it adds uploaded image url (of superbase) into the markdown so that when ai agent retrieves the markdown it can directly render the retrieved image with annotation below.",
        "width": 260,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1040,
        -640
      ],
      "id": "3da6dc09-9923-4545-bd2e-71722f28785a",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "content": "**NOTE**: Code node is setup so that the image annotation is also combined into the markdown as context for retrieval.",
        "height": 120,
        "width": 220,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1168,
        928
      ],
      "id": "abcee77f-cfbc-4d93-9158-9cf89670d547",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "content": "**NOTE**: Extracts relevant triggered bucket name and folder id to access later in the flow. (as well as to access and download files from the triggered folder.)",
        "width": 200,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3024,
        -624
      ],
      "id": "bd9916ad-713b-4694-ac5a-bd8ea2cc775b",
      "name": "Sticky Note8"
    },
    {
      "parameters": {
        "jsCode": "// take each page, remove all Markdown image refs, return cleaned items\nreturn items.map(item => {\n  const pages = item.json.pages?.map(page => {\n    page.markdown = page.markdown.replace(/!\\[.*?\\]\\(.*?\\)/g, '');\n    return page;\n  });\n  return {\n    json: {\n      ...item.json,\n      pages,\n    }\n  };\n});\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1328,
        1072
      ],
      "id": "bb9b97dc-eac5-43d8-a4f6-7d8d3b2840c4",
      "name": "Clean markdown"
    }
  ],
  "connections": {
    "HTTP Request-Upload file to Mistral": {
      "main": [
        [
          {
            "node": "HTTP Request Get signed URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request Get signed URL": {
      "main": [
        [
          {
            "node": "HTTP Request Image BBox Annotation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request Image BBox Annotation": {
      "main": [
        [
          {
            "node": "Clean markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out - by pages": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Upload PDF to Mistral": {
      "main": [
        [
          {
            "node": "HTTP Request - Get signed URL if uploaded to Mistral",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Get signed URL if uploaded to Mistral": {
      "main": [
        [
          {
            "node": "HTTP Request - OCR and Image Annotation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - OCR and Image Annotation": {
      "main": [
        [
          {
            "node": "Split Out - (pages)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Split Out - (pages)": {
      "main": [
        [
          {
            "node": "Split Out - (images)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out - (images)": {
      "main": [
        [
          {
            "node": "Extract the file name, id, and annotation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract the file name, id, and annotation": {
      "main": [
        [
          {
            "node": "Extract image_base64",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extract image_base64": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Upload base64 strings to superbase storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Uploaded Filename": {
      "main": [
        [
          {
            "node": "Merge results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload base64 strings to superbase storage": {
      "main": [
        [
          {
            "node": "Get Uploaded Filename",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge results": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Download Drive File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Split Out-pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader (image)": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store (image)",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI (image)": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store (image)",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter (image)": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader (image)",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Code (B)": {
      "main": [
        [
          {
            "node": "Supabase Vector Store (image)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Metadata": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Drive File": {
      "main": [
        [
          {
            "node": "HTTP Request - Upload PDF to Mistral",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out-pages": {
      "main": [
        [
          {
            "node": "Code (B)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (B) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_b) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (C) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_c) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (D) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_d) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (E) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_e) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (F) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_f) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (G) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_g) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (H) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_h) - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_h) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_g) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_f) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_e) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_d) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_c) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_b) - Text": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket - Text": {
      "main": [
        [
          {
            "node": "Get File Metadata - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Metadata - Text": {
      "main": [
        [
          {
            "node": "Search files and folders - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders - Text": {
      "main": [
        [
          {
            "node": "Download Drive File - Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Drive File - Text": {
      "main": [
        [
          {
            "node": "HTTP Request-Upload file to Mistral",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (B) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_b) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (C) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_c) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (D) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_d) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (E) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_e) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (F) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_f) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (G) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_g) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger (H) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket (code_h) - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_b) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_c) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_d) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_e) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_f) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_g) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket (code_h) - Image": {
      "main": [
        [
          {
            "node": "Superbase Bucket - Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Superbase Bucket - Image": {
      "main": [
        [
          {
            "node": "Get File Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean markdown": {
      "main": [
        [
          {
            "node": "Split Out - by pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "11e7e3a8-71a2-48df-9fe8-77ef8dda45ad",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "nUptcJJjf7cfDcu0",
  "tags": [
    {
      "createdAt": "2025-06-27T09:21:16.198Z",
      "updatedAt": "2025-06-27T09:21:16.198Z",
      "id": "1ahgb9qBZxOEn32b",
      "name": "Demo"
    },
    {
      "createdAt": "2025-06-27T09:21:16.185Z",
      "updatedAt": "2025-06-27T09:21:16.185Z",
      "id": "NAQ0F1UmDrraK5ci",
      "name": "Getting Automated"
    },
    {
      "createdAt": "2025-06-27T09:21:16.193Z",
      "updatedAt": "2025-06-27T09:21:16.193Z",
      "id": "qL16Me4Tq77kaW8d",
      "name": "For Distribution"
    }
  ]
}