{
  "id": "tVgB8yDJ50qkgXkk",
  "meta": {
    "instanceId": "fdabf1bc7f0608d0f68d957aa79273c8b7e2d92bff3cc3d974698022af7c3d64",
    "templateId": "2753",
    "templateCredsSetupCompleted": true
  },
  "name": "Retrieve Google Drive documents using Pinecone and OpenAI.",
  "tags": [
    {
      "id": "Vuys3YNCF78ZYDNm",
      "name": "RAG",
      "createdAt": "2026-01-11T09:42:41.482Z",
      "updatedAt": "2026-01-11T09:42:41.482Z"
    },
    {
      "id": "brIAuBQxDRKD6cH1",
      "name": "Chatbot",
      "createdAt": "2026-01-11T09:42:54.790Z",
      "updatedAt": "2026-01-11T09:42:54.790Z"
    }
  ],
  "nodes": [
    {
      "id": "14a0099f-eb2a-4b5e-876e-11c8c1f3df84",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1440,
        0
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "open-ai-3072",
          "cachedResultName": "open-ai-3072"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "credential-id",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5bf95b79-eafe-48c7-86ea-a13ced15611b",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "onError": "continueErrorOutput",
      "position": [
        1552,
        208
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "binaryMode": "specificField"
      },
      "typeVersion": 1,
      "alwaysOutputData": false
    },
    {
      "id": "96970907-bf3c-4d4d-8840-676438a71f95",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1776,
        320
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 100
      },
      "typeVersion": 1
    },
    {
      "id": "c0c13ac9-d126-439b-838f-d9c50fa1d309",
      "name": "Vector Store Tool",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        1312,
        1344
      ],
      "parameters": {
        "name": "company_documents_tool",
        "topK": 10,
        "description": "Retrieve information from any company documents"
      },
      "typeVersion": 1
    },
    {
      "id": "8c2ff1ee-7982-42b9-bea7-d466ead05e65",
      "name": "Pinecone Vector Store (Retrieval)",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1152,
        1504
      ],
      "parameters": {
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "open-ai-3072",
          "cachedResultName": "open-ai-3072"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "credential-id",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "107d6722-a8ba-4234-8eff-075c8180b1a0",
      "name": "Download File From Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueErrorOutput",
      "position": [
        1168,
        0
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "fileName": "={{ $json.name }}"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "a896f7d1-6f8f-44d1-8783-2adef0005c58",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        1136
      ],
      "parameters": {
        "width": 1216,
        "height": 576,
        "content": "## Chat with company documents\n\n### Available chat tool with customized css style\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6c242bef-9cb0-41a2-af93-603e5b5ee267",
      "name": "Google Drive File Updated",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        112,
        704
      ],
      "parameters": {
        "event": "fileUpdated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1-4lBhk3UPcaMSb1_7uE7-jsgRMqcP6M8",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1-4lBhk3UPcaMSb1_7uE7-jsgRMqcP6M8",
          "cachedResultName": "PDF"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fb8c97e9-54b6-46d3-8b15-ee58b8af685e",
      "name": "Google Drive File Created",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        112,
        496
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {
          "fileType": "all"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1-4lBhk3UPcaMSb1_7uE7-jsgRMqcP6M8",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1-4lBhk3UPcaMSb1_7uE7-jsgRMqcP6M8",
          "cachedResultName": "PDF"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "32bcde62-2e41-4431-b432-c82a5fe20318",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        976,
        1456
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "19843767-9ac7-4ada-87c9-e11fcf282ea8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        288
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 592,
        "content": "## Add documents to vector store when updating or creating new documents in Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "00cea317-6e8e-4997-847e-1b0abbf11934",
      "name": "Search files and folders",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        336,
        -208
      ],
      "parameters": {
        "limit": 500,
        "filter": {},
        "options": {},
        "resource": "fileFolder",
        "queryString": "='1-4lBhk3UPcaMSb1_7uE7-jsgRMqcP6M8' in parents and (mimeType = 'application/pdf' or mimeType = 'text/plain') and trashed = false",
        "searchMethod": "query"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "bd60461c-3c81-41e5-9b66-774c6062bf90",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -112,
        -112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c849a85d-237a-4904-9efb-51f7ae9bb186",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1776,
        0
      ],
      "webhookId": "d5ffe7ef-ddc4-4e54-8b02-3eab78a4c078",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "48898663-6588-4d71-bda0-30724b636069",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        624,
        1248
      ],
      "webhookId": "f357c0d5-b9a1-4c8f-b124-e00925e93a07",
      "parameters": {
        "public": true,
        "options": {
          "title": "Finding documents...",
          "subtitle": "",
          "customCss": "/* =========================================================\n   FONT\n   ========================================================= */\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');\n\n\n/* =========================================================\n   LIGHT THEME (DEFAULT)\n   ========================================================= */\n:root {\n  /* ---------- COLORS ---------- */\n  --chat--color-primary: #2563eb;\n  --chat--color-primary-shade-50: #1d4ed8;\n  --chat--color-primary-shade-100: #1e40af;\n\n  --chat--color-secondary: #10b981;\n  --chat--color-secondary-shade-50: #059669;\n\n  --chat--color-white: #ffffff;\n  --chat--color-light: #f8fafc;\n  --chat--color-light-shade-50: #e5e7eb;\n  --chat--color-light-shade-100: #d1d5db;\n\n  --chat--color-medium: #cbd5e1;\n  --chat--color-dark: #0f172a;\n  --chat--color-disabled: #cbd5e1;\n  --chat--color-typing: #475569;\n\n  /* ---------- TYPOGRAPHY ---------- */\n  --chat--font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n  --chat--message--font-size: 1rem;\n  --chat--message-line-height: 1.65;\n  --chat--heading--font-size: 1.3em;\n  --chat--subtitle--font-size: 0.95em;\n  --chat--input--font-size: 1rem;\n  --chat--input--line-height: 1.6;\n\n  /* ---------- LAYOUT ---------- */\n  --chat--spacing: 1.1rem;\n  --chat--border-radius: 0.75rem;\n\n  /* ---------- WINDOW ---------- */\n  --chat--window--width: 460px;\n  --chat--window--height: 680px;\n  --chat--window--border: 1px solid var(--chat--color-light-shade-50);\n\n  /* ---------- HEADER ---------- */\n  --chat--header--background: var(--chat--color-dark);\n  --chat--header--color: var(--chat--color-light);\n\n  /* ---------- BODY ---------- */\n  --chat--body--background: var(--chat--color-light);\n\n  /* ---------- MESSAGES ---------- */\n  --chat--message--bot--background: var(--chat--color-white);\n  --chat--message--bot--color: var(--chat--color-dark);\n  --chat--message--bot--border: 1px solid var(--chat--color-light-shade-50);\n\n  --chat--message--user--background: var(--chat--color-secondary);\n  --chat--message--user--color: var(--chat--color-white);\n\n  /* ---------- INPUT ---------- */\n  --chat--input--background: var(--chat--color-white);\n  --chat--input--text-color: var(--chat--color-dark);\n  --chat--input--placeholder--color: #94a3b8;\n}\n\n\n/* =========================================================\n   DARK MODE (AUTOMATIC)\n   ========================================================= */\n@media (prefers-color-scheme: dark) {\n  :root {\n    --chat--color-white: #020617;\n    --chat--color-light: #020617;\n    --chat--color-light-shade-50: #1e293b;\n    --chat--color-light-shade-100: #334155;\n\n    --chat--color-dark: #e5e7eb;\n    --chat--color-medium: #475569;\n    --chat--color-typing: #94a3b8;\n\n    --chat--body--background: #020617;\n\n    --chat--header--background: #020617;\n    --chat--header--color: #e5e7eb;\n\n    --chat--message--bot--background: #020617;\n    --chat--message--bot--color: #e5e7eb;\n    --chat--message--bot--border: 1px solid #1e293b;\n\n    --chat--message--user--background: #10b981;\n    --chat--message--user--color: #020617;\n\n    /* INPUT – FIX DEFINITIVO */\n    --chat--input--background: #020617;\n    --chat--input--text-color: #e5e7eb;\n    --chat--input--placeholder--color: #64748b;\n  }\n}\n\n\n/* =========================================================\n   BASE ELEMENTS\n   ========================================================= */\n.chat-message {\n  max-width: 70%;\n  font-family: var(--chat--font-family);\n  font-size: var(--chat--message--font-size);\n  line-height: var(--chat--message-line-height);\n  letter-spacing: 0.01em;\n}\n\n.chat-message.bot {\n  font-weight: 500;\n}\n\n.chat-message.user {\n  font-weight: 400;\n}\n\n.chat-header,\n.chat-header * {\n  font-family: var(--chat--font-family);\n  font-weight: 600;\n}\n\n\n/* =========================================================\n   INPUT – VISIBILITY GUARANTEED\n   ========================================================= */\n.chat-input,\ntextarea,\ninput {\n  font-family: var(--chat--font-family);\n  font-size: var(--chat--input--font-size);\n  line-height: var(--chat--input--line-height);\n  color: var(--chat--input--text-color);\n  background-color: var(--chat--input--background);\n  caret-color: var(--chat--input--text-color);\n}\n\n.chat-input::placeholder,\ntextarea::placeholder,\ninput::placeholder {\n  color: var(--chat--input--placeholder--color);\n}\n\n\n/* =========================================================\n   RAG – SOURCE / DOCUMENT BADGE\n   ========================================================= */\n.rag-source {\n  display: inline-block;\n  margin-left: 0.4rem;\n  padding: 0.15rem 0.5rem;\n  font-size: 0.75rem;\n  font-weight: 600;\n  border-radius: 999px;\n  background: rgba(37, 99, 235, 0.1);\n  color: var(--chat--color-primary);\n}\n\n\n/* =========================================================\n   RAG – DOCUMENT TYPE ICONS\n   ========================================================= */\n.rag-doc {\n  font-weight: 500;\n}\n\n.rag-doc::before {\n  margin-right: 0.35rem;\n}\n\n.rag-doc.pdf::before { content: \"📄\"; }\n.rag-doc.sheet::before { content: \"📊\"; }\n.rag-doc.text::before { content: \"📑\"; }\n\n\n/* =========================================================\n   RAG – CONFIDENCE / MATCH SCORE\n   ========================================================= */\n.rag-confidence {\n  display: inline-flex;\n  align-items: center;\n  margin-left: 0.5rem;\n  padding: 0.15rem 0.45rem;\n  font-size: 0.75rem;\n  font-weight: 600;\n  border-radius: 999px;\n  background: rgba(15, 23, 42, 0.06);\n  color: #334155;\n}\n\n.rag-confidence::before {\n  content: \"match\";\n  margin-right: 0.3rem;\n  opacity: 0.7;\n}\n\n.rag-confidence.high {\n  background: rgba(16, 185, 129, 0.15);\n  color: #065f46;\n}\n\n.rag-confidence.medium {\n  background: rgba(234, 179, 8, 0.15);\n  color: #92400e;\n}\n\n.rag-confidence.low {\n  background: rgba(239, 68, 68, 0.15);\n  color: #7f1d1d;\n}\n\n\n/* =========================================================\n   RAG – NUMERIC CITATIONS (PAPER STYLE)\n   ========================================================= */\n.rag-ref {\n  display: inline-block;\n  margin-left: 0.15rem;\n  padding: 0 0.35rem;\n  font-size: 0.75rem;\n  font-weight: 600;\n  border-radius: 4px;\n  color: var(--chat--color-primary);\n  text-decoration: none;\n  border: 1px solid currentColor;\n}\n\n.rag-ref:hover {\n  background: var(--chat--color-primary);\n  color: #ffffff;\n}\n\n\n/* =========================================================\n   RAG – INLINE DOCUMENT PREVIEW\n   ========================================================= */\n.rag-preview {\n  margin-top: 0.75rem;\n  border-radius: 0.5rem;\n  overflow: hidden;\n  border: 1px solid var(--chat--color-light-shade-50);\n}\n\n.rag-preview summary {\n  padding: 0.5rem 0.75rem;\n  font-size: 0.85rem;\n  font-weight: 600;\n  cursor: pointer;\n  background: var(--chat--color-light);\n}\n\n.rag-preview summary:hover {\n  background: var(--chat--color-light-shade-50);\n}\n\n.rag-preview iframe {\n  width: 100%;\n  height: 320px;\n  border: none;\n}\n\n\n/* =========================================================\n   CODE BLOCKS\n   ========================================================= */\n.chat-message pre {\n  margin-top: 0.75rem;\n  padding: 0.75rem;\n  border-radius: 0.5rem;\n  background: rgba(0, 0, 0, 0.05);\n  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n  font-size: 0.9em;\n}\n\n@media (prefers-color-scheme: dark) {\n  .chat-message pre {\n    background: rgba(255, 255, 255, 0.06);\n  }\n}\n",
          "responseMode": "lastNode",
          "allowFileUploads": true,
          "inputPlaceholder": "Tell me what you need.",
          "allowedFilesMimeTypes": "application/pdf"
        },
        "initialMessages": "Hi!\nHow cal I help you?"
      },
      "typeVersion": 1.4
    },
    {
      "id": "a2c2f1fb-343c-4e14-9558-3d9d0b13559c",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        800,
        1408
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "gpt-5.2"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ce98d6ae-9fbc-463f-9eb7-4a6b71ca89f8",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1616,
        1472
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "gpt-5.2"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2870d0f4-3da0-445a-b4f7-26a661892dee",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1376,
        1600
      ],
      "parameters": {
        "model": "text-embedding-3-large",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6bc490b7-53e7-42dc-a304-39c6afd6dcaa",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1376,
        208
      ],
      "parameters": {
        "model": "text-embedding-3-large",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c9807b69-3e69-4565-b675-a1fbc8922c2b",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        752,
        -240
      ],
      "webhookId": "026edd91-80fc-4df5-aa70-5ea6455399d7",
      "parameters": {
        "sendTo": "user@example.com",
        "message": "Il flusso è terminato con successo.",
        "options": {},
        "subject": "=Flow terminated {{ $workflow.name }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "credential-id",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c3d3d370-7c01-4394-8f73-5d0bc6812cd5",
      "name": "Download File From Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueErrorOutput",
      "position": [
        1056,
        592
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "fileName": "={{ $json.name }}"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "bddb2c85-08f0-4e5d-8b51-b282064dece8",
      "name": "Pinecone Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1376,
        576
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "open-ai-3072",
          "cachedResultName": "open-ai-3072"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "credential-id",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5c49a685-8ca8-4a95-a8c7-d5d325101432",
      "name": "Embeddings OpenAI2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1296,
        768
      ],
      "parameters": {
        "model": "text-embedding-3-large",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "credential-id",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c0a1146-8b18-4155-a7f1-d53816a41ba1",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "onError": "continueErrorOutput",
      "position": [
        1472,
        752
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "binaryMode": "specificField"
      },
      "typeVersion": 1,
      "alwaysOutputData": false
    },
    {
      "id": "b640dd1a-9d5d-4e1c-8298-0aeb0f6ec3d8",
      "name": "Recursive Character Text Splitter1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1504,
        928
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 100
      },
      "typeVersion": 1
    },
    {
      "id": "936a8ca2-a608-42ec-9649-1596e2f36098",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -176
      ],
      "parameters": {
        "color": 3,
        "width": 736,
        "height": 768,
        "content": "## RAG with Google Drive, Pinecone, and OpenAI\n\nThis workflow builds a living knowledge base from your Google Drive and lets users chat with company documents in real time. Files are continuously indexed into a vector database, so answers stay aligned with the latest versions without manual re-uploads or brittle sync jobs. The result is a clean RAG (Retrieval-Augmented Generation) loop: documents in, vectors out, answers grounded in sources.\n\n### How it works\n\nOn the ingestion side, the workflow monitors a specific Google Drive folder for file creation, updates, and deletions.\nWhen a file is created or updated, it is downloaded, parsed, split into chunks, embedded with OpenAI embeddings, and stored in a Pinecone index. Chunking with overlap ensures good semantic recall without bloating the index.\n\nWhen a file is deleted from Google Drive, the workflow proactively removes the corresponding vectors from Pinecone. This prevents orphaned embeddings, stale answers, and the classic RAG failure mode where the model confidently cites documents that no longer exist.\n\nOn the query side, a chat trigger sends user questions to an AI Agent. The agent retrieves the most relevant vectors from Pinecone and passes them to an OpenAI chat model. A short windowed memory keeps conversational continuity without contaminating retrieval. Answers are generated strictly from retrieved content, with optional references to source files.\n\n### Setup steps\n\nConfigure the Google Drive triggers (created, updated, deleted) on a target folder and apply file-type filters. Set up a Pinecone index compatible with your embedding model and connect OpenAI for embeddings and chat. Tune the text splitter for chunk size and overlap. Finally, wire the Vector Store Tool to the AI Agent and enable the chat trigger. Once active, the system stays aligned with Drive automatically—add, update, or delete files, and Pinecone follows suit."
      },
      "typeVersion": 1
    },
    {
      "id": "212199f2-47cf-423f-81a3-c482d56fe1dd",
      "name": "Pinecone – Delete All Vectors",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        96,
        -144
      ],
      "parameters": {
        "url": "https://open-ai-3072-71cwk85.svc.aped-4627-b74a.pinecone.io/vectors/delete",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"deleteAll\": true\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Api-Key",
              "value": "[Your API KEY]"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "30c76f1d-d945-4cf6-bd9e-0233abea69a1",
      "name": "Loop Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        544,
        -176
      ],
      "parameters": {
        "options": {
          "reset": false
        },
        "batchSize": 30
      },
      "typeVersion": 3
    },
    {
      "id": "521867f9-a510-45d9-9960-e2ca95ebf8fa",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -352
      ],
      "parameters": {
        "color": 4,
        "width": 1520,
        "height": 816,
        "content": "## Embedding entire folder\n\n### Upload all documents from a folder "
      },
      "typeVersion": 1
    },
    {
      "id": "7d132873-bd24-4fac-b329-881c55267e12",
      "name": "Documents finder",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        896,
        1248
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are an assistant that helps users retrieve information from documents stored in a RAG archive.\nWhere possible, include the name or names of the files in which the information was found.",
          "returnIntermediateSteps": false
        }
      },
      "typeVersion": 1.7
    },
    {
      "id": "8b9e7cad-7cd1-4719-867b-23cc50876117",
      "name": "Filter PDF files",
      "type": "n8n-nodes-base.filter",
      "position": [
        352,
        496
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1c62b8c9-a70c-44cc-8842-d5c8e180fc61",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.mimeType }}",
              "rightValue": "=application/pdf"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "37e1557e-47eb-4b17-8400-430b02b8aa1d",
      "name": "Filter PDF files1",
      "type": "n8n-nodes-base.filter",
      "position": [
        368,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d2c881b9-de6f-4e5c-9884-a9188c8d38b7",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.mimeType }}",
              "rightValue": "=application/pdf"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "c125e787-2a8c-4136-a31b-c5bfa8b55b9e",
      "name": "If length > 0",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        496
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b75f6b19-729d-41dd-a9c3-37851ea9b2dc",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $items().length > 0 }}\n",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "31847f2b-f4cf-415b-83af-1ed9ce04af05",
      "name": "If length > 0_",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b75f6b19-729d-41dd-a9c3-37851ea9b2dc",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $items().length > 0 }}\n",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "dbe33969-9c03-495f-b4d0-21db42636a15",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        512
      ],
      "parameters": {
        "color": 6,
        "width": 736,
        "height": 576,
        "content": "## Embedding documents information into Pinecone vector database\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "7TaexhgP7sonxvTB",
    "timeSavedMode": "fixed",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "9769b915-eb66-4b8f-8d40-abe591324f03",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Items": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download File From Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If length > 0": {
      "main": [
        [
          {
            "node": "Download File From Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If length > 0_": {
      "main": [
        [
          {
            "node": "Download File From Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Documents finder": {
      "main": [
        []
      ]
    },
    "Filter PDF files": {
      "main": [
        [
          {
            "node": "If length > 0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store (Retrieval)",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Filter PDF files1": {
      "main": [
        [
          {
            "node": "If length > 0_",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Documents finder",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Vector Store Tool": {
      "ai_tool": [
        [
          {
            "node": "Documents finder",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI2": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Vector Store Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "Documents finder",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Loop Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive File Created": {
      "main": [
        [
          {
            "node": "Filter PDF files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive File Updated": {
      "main": [
        [
          {
            "node": "Filter PDF files1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Documents finder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File From Google Drive": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone – Delete All Vectors": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File From Google Drive1": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store (Retrieval)": {
      "ai_vectorStore": [
        [
          {
            "node": "Vector Store Tool",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Pinecone – Delete All Vectors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}