{
  "name": "Build a Google Drive internal knowledge base with OpenAI and Pinecone",
  "nodes": [
    {
      "id": "4e498901-71b0-4531-a13f-73cbc515bf3e",
      "name": "Log to Document Registry",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        816,
        -96
      ]
    },
    {
      "id": "ab20bb84-ff23-4b27-bcfa-313745cec10c",
      "name": "Notify Ingestion Complete",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1040,
        -96
      ]
    },
    {
      "id": "081355ec-701b-4cf1-b118-af1545180a59",
      "name": "Read Document Registry",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        1200
      ]
    },
    {
      "id": "1f300b91-98f4-4c93-a683-a28ad57d6dac",
      "name": "Update Document Registry",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1776,
        1104
      ]
    },
    {
      "id": "2f8e444f-82d7-4d13-9431-bd1ea81980bf",
      "name": "Manual Ingestion Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -240,
        -96
      ]
    },
    {
      "id": "d2e30c18-88dc-40e6-a6bf-464d7a79662d",
      "name": "List Knowledge Base Docs",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -16,
        -96
      ]
    },
    {
      "id": "d4da2a9e-078a-4637-b445-e6fd1fc375ed",
      "name": "Download Doc as Text",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        192,
        -96
      ]
    },
    {
      "id": "f3ec1400-d62f-4c9e-a192-24c66c6efc86",
      "name": "Store Embeddings in Pinecone",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        480,
        -96
      ]
    },
    {
      "id": "a61f500f-fa9a-4a19-b701-c00a9ba4d67d",
      "name": "Load Document Data",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        656,
        128
      ]
    },
    {
      "id": "aab901d9-7927-4212-9aa4-db8e670dc326",
      "name": "Split Into Chunks",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        656,
        288
      ]
    },
    {
      "id": "d18aa2c3-9339-4e18-b0ed-12d849ab12d4",
      "name": "Generate Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        448,
        144
      ]
    },
    {
      "id": "7662ee08-55b8-4136-b12b-ebce56d1c8b0",
      "name": "Question Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -240,
        592
      ]
    },
    {
      "id": "3fdda52b-72a1-4bbb-9fd1-fe0e2ead8ffb",
      "name": "Extract Question & User",
      "type": "n8n-nodes-base.code",
      "position": [
        -32,
        592
      ]
    },
    {
      "id": "20b8ac27-bb21-48c4-970e-47c901b48928",
      "name": "Search Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        240,
        592
      ]
    },
    {
      "id": "c588c289-f8be-4d81-9232-6f74b2ca0a3c",
      "name": "Generate Query Embedding",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        208,
        832
      ]
    },
    {
      "id": "9666c6f5-8111-4358-90d9-ad2404efa47f",
      "name": "Build RAG Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        592,
        592
      ]
    },
    {
      "id": "30135c15-c7e1-476d-b44f-c1d265f6e508",
      "name": "Answer Generator",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        800,
        592
      ]
    },
    {
      "id": "ff012edb-c097-49a4-9463-bbb1e4bafa0d",
      "name": "Parse AI Answer",
      "type": "n8n-nodes-base.code",
      "position": [
        1152,
        592
      ]
    },
    {
      "id": "d71d33a2-379d-4413-a507-d811eadef9a0",
      "name": "Log Q&A to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1376,
        592
      ]
    },
    {
      "id": "d2bf69f8-c574-4d24-8131-3089614ab464",
      "name": "Send Answer Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1584,
        592
      ]
    },
    {
      "id": "e762c285-11e8-4094-bb4a-6787ebd9c943",
      "name": "Weekly Sunday 11AM Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -304,
        1200
      ]
    },
    {
      "id": "561dc99f-904c-4cff-885b-8f00be3c5a57",
      "name": "List Knowledge Base Docs1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -80,
        1200
      ]
    },
    {
      "id": "1e1e6217-3c3f-4055-abf4-a7119e873641",
      "name": "Detect New or Updated Docs",
      "type": "n8n-nodes-base.code",
      "position": [
        384,
        1200
      ]
    },
    {
      "id": "87b6e7f3-1d48-4bb9-af3b-297e5c64efdd",
      "name": "IF New Docs Found",
      "type": "n8n-nodes-base.if",
      "position": [
        592,
        1200
      ]
    },
    {
      "id": "f25316cc-8eb9-4446-9d6b-6737261b706e",
      "name": "Prepare Docs for Re-ingestion",
      "type": "n8n-nodes-base.code",
      "position": [
        848,
        1104
      ]
    },
    {
      "id": "11af64f5-608e-4f83-9776-cda58253ea8a",
      "name": "Download Updated Docs",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1056,
        1104
      ]
    },
    {
      "id": "954505bc-450b-41e1-9d88-be0dba2bebf5",
      "name": "Re-ingest into Pinecone",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1280,
        1104
      ]
    },
    {
      "id": "57a5e123-b40f-4304-bf7d-41d3b9917871",
      "name": "Load Document Data1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1456,
        1328
      ]
    },
    {
      "id": "0ba757d1-dcfa-439a-9868-daca975ad6da",
      "name": "Split Into Chunks1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1456,
        1488
      ]
    },
    {
      "id": "5c0e34d0-51ed-4f05-8212-dde1270a7e90",
      "name": "Generate Embeddings1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1248,
        1344
      ]
    },
    {
      "id": "a14a1e5b-51f6-4cc4-819f-c85c7264ec31",
      "name": "Build KB Digest Email",
      "type": "n8n-nodes-base.code",
      "position": [
        1968,
        1104
      ]
    },
    {
      "id": "a576a867-f567-4198-bd7a-1e648781d14d",
      "name": "Build KB Digest Email1",
      "type": "n8n-nodes-base.code",
      "position": [
        928,
        1664
      ]
    },
    {
      "id": "a24dbe19-e6e2-4ffa-8239-42c7ddc16e43",
      "name": "Send Weekly KB Digest",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2176,
        1104
      ]
    },
    {
      "id": "c876e977-e549-4071-8813-ad3a5e8782d2",
      "name": "Send Weekly KB Digest1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1136,
        1664
      ]
    },
    {
      "id": "1b5f30c3-ef49-45f2-bbc6-584c88db4258",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        -832
      ],
      "parameters": {
        "width": 400,
        "height": 720,
        "content": "## Workflow Overview\n\n\n\nStop answering the same company questions over and \nover. This workflow turns your Google Drive documents \ninto a searchable AI knowledge base. Ask it anything \nabout your comp"
      }
    },
    {
      "id": "39959dab-ce20-444a-ba2a-d886fffbf70b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -272
      ],
      "parameters": {
        "width": 1536,
        "height": 704,
        "content": "Run this manually when adding new documents. Reads  all Google Docs from your Knowledge Base folder,  splits them into chunks, converts to embeddings,  and stores everything in Pinecone. Logs each doc"
      }
    },
    {
      "id": "70976dfe-7d68-4c60-801f-c7237d836519",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        480
      ],
      "parameters": {
        "width": 2144,
        "height": 496,
        "content": "Always active via webhook. Takes any question as a POST request, searches Pinecone for the 5 most  relevant chunks, sends context to GPT-4o, and  returns a grounded answer with source citation  and co"
      }
    },
    {
      "id": "72c868a8-636b-432c-8536-cf75f162b191",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        1024
      ],
      "parameters": {
        "width": 2816,
        "height": 832,
        "content": "Runs every Sunday at 11AM. Compares your Drive folder against the Document Registry, detects new  or updated docs, re-ingests them into Pinecone automatically, and emails a weekly digest of your full "
      }
    }
  ],
  "connections": {
    "Parse AI Answer": {
      "main": [
        [
          {
            "node": "Log Q&A to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer Generator": {
      "main": [
        [
          {
            "node": "Parse AI Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build RAG Prompt": {
      "main": [
        [
          {
            "node": "Answer Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Question Webhook": {
      "main": [
        [
          {
            "node": "Extract Question & User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF New Docs Found": {
      "main": [
        [
          {
            "node": "Prepare Docs for Re-ingestion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build KB Digest Email1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Q&A to Sheets": {
      "main": [
        [
          {
            "node": "Send Answer Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Into Chunks": {
      "ai_textSplitter": [
        [
          {
            "node": "Load Document Data",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Load Document Data": {
      "ai_document": [
        [
          {
            "node": "Store Embeddings in Pinecone",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Split Into Chunks1": {
      "ai_textSplitter": [
        [
          {
            "node": "Load Document Data1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Generate Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Store Embeddings in Pinecone",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Load Document Data1": {
      "ai_document": [
        [
          {
            "node": "Re-ingest into Pinecone",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Download Doc as Text": {
      "main": [
        [
          {
            "node": "Store Embeddings in Pinecone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Embeddings1": {
      "ai_embedding": [
        [
          {
            "node": "Re-ingest into Pinecone",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Build KB Digest Email": {
      "main": [
        [
          {
            "node": "Send Weekly KB Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Updated Docs": {
      "main": [
        [
          {
            "node": "Re-ingest into Pinecone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Knowledge Base": {
      "main": [
        [
          {
            "node": "Build RAG Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Weekly KB Digest": {
      "main": [
        []
      ]
    },
    "Build KB Digest Email1": {
      "main": [
        [
          {
            "node": "Send Weekly KB Digest1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Document Registry": {
      "main": [
        [
          {
            "node": "Detect New or Updated Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Question & User": {
      "main": [
        [
          {
            "node": "Search Knowledge Base",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Re-ingest into Pinecone": {
      "main": [
        [
          {
            "node": "Update Document Registry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Query Embedding": {
      "ai_embedding": [
        [
          {
            "node": "Search Knowledge Base",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "List Knowledge Base Docs": {
      "main": [
        [
          {
            "node": "Download Doc as Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Document Registry": {
      "main": [
        [
          {
            "node": "Notify Ingestion Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Ingestion Trigger": {
      "main": [
        [
          {
            "node": "List Knowledge Base Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Document Registry": {
      "main": [
        [
          {
            "node": "Build KB Digest Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Knowledge Base Docs1": {
      "main": [
        [
          {
            "node": "Read Document Registry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect New or Updated Docs": {
      "main": [
        [
          {
            "node": "IF New Docs Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Sunday 11AM Trigger": {
      "main": [
        [
          {
            "node": "List Knowledge Base Docs1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Embeddings in Pinecone": {
      "main": [
        [
          {
            "node": "Log to Document Registry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Docs for Re-ingestion": {
      "main": [
        [
          {
            "node": "Download Updated Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}