{
  "name": "Pdf RAG agent with Telegram chat & auto-ingestion from Google Drive",
  "nodes": [
    {
      "id": "1bb5bca6-10c4-4d9e-9435-3400fe80d2aa",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        -960,
        -1648
      ]
    },
    {
      "id": "5759f41a-5c02-4d3d-8bee-1da84290bd39",
      "name": "Azure OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        304,
        -2048
      ]
    },
    {
      "id": "587a276a-5405-418f-8c19-462cdd10fb36",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        304,
        -2256
      ]
    },
    {
      "id": "8538610d-7484-4096-affa-5855d3825d36",
      "name": "Send PDF File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -656,
        -2176
      ]
    },
    {
      "id": "e39c3c95-a9d0-4451-8ae3-92ff9b78eb50",
      "name": "Embeddings Mistral Cloud",
      "type": "@n8n/n8n-nodes-langchain.embeddingsMistralCloud",
      "position": [
        -928,
        -1344
      ]
    },
    {
      "id": "ea109c37-e951-4947-9b4e-5f24dcac0dfa",
      "name": "Postgres PGVector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "position": [
        -928,
        -1824
      ]
    },
    {
      "id": "32bcfb09-99d7-4883-b0bb-7c51b294dfff",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1040,
        -2256
      ]
    },
    {
      "id": "dc536bb3-09b4-4e99-9170-6d5ce7536590",
      "name": "List All File Names",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1232,
        -2256
      ]
    },
    {
      "id": "f71096a3-a5af-4567-95ce-a63869849975",
      "name": "Download Corresponding File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -848,
        -2176
      ]
    },
    {
      "id": "c5e62513-0da7-4fb3-a33b-50c0b876948d",
      "name": "Run Ingestion",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1424,
        -2256
      ]
    },
    {
      "id": "d73b903d-b030-42b7-a1f0-44eb087ff017",
      "name": "PDF Ingest Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1120,
        -1824
      ]
    },
    {
      "id": "673e5655-924d-4b87-8b9d-a8d0d92fbea3",
      "name": "Token Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterTokenSplitter",
      "position": [
        -960,
        -1488
      ]
    },
    {
      "id": "22ad6959-4b23-40ca-97d6-a1780e93b81e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -2336
      ],
      "parameters": {
        "width": 1184,
        "height": 384,
        "content": "## LOAD FILES & SEND THEM TO WEBHOOK"
      }
    },
    {
      "id": "152563cd-493f-4862-b1df-9ce36d25c2c1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -1888
      ],
      "parameters": {
        "width": 1184,
        "height": 352,
        "content": "## RECEIVE FILES AND INGEST THEM"
      }
    },
    {
      "id": "7025aca3-98b9-4578-87a4-964fa1404d09",
      "name": "Postgres PGVector Store2",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "position": [
        368,
        -1760
      ]
    },
    {
      "id": "04f31fae-759f-4568-9c1c-d0bb70bcb9a2",
      "name": "Embeddings Mistral Cloud2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsMistralCloud",
      "position": [
        368,
        -1600
      ]
    },
    {
      "id": "c1e2f23a-661b-4f9f-841e-45e7a20fcb47",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1376,
        -1072
      ]
    },
    {
      "id": "d1b46c07-aed2-4a8d-8cf7-8c32a9f5d99f",
      "name": "Azure OpenAI Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        144,
        -880
      ]
    },
    {
      "id": "24829661-5ed7-42fd-a919-dd92aa429f79",
      "name": "AI Agent2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        144,
        -1088
      ]
    },
    {
      "id": "eef6da5b-38d7-44b1-9fce-368aba504860",
      "name": "Postgres PGVector Store3",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "position": [
        208,
        -576
      ]
    },
    {
      "id": "61176586-9a2e-45b9-8592-bf86c989ebf7",
      "name": "Embeddings Mistral Cloud3",
      "type": "@n8n/n8n-nodes-langchain.embeddingsMistralCloud",
      "position": [
        208,
        -416
      ]
    },
    {
      "id": "28a0b6b9-8be9-491b-83e9-54ecceee4e87",
      "name": "Send a Text Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        448,
        -1088
      ]
    },
    {
      "id": "6eb22528-4c87-44cb-a152-7abeb45c43ff",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        -736
      ]
    },
    {
      "id": "f381d0a0-7b41-489c-9499-467e77620c47",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -2336
      ],
      "parameters": {
        "width": 704,
        "height": 304,
        "content": "# CANVAS CHAT"
      }
    },
    {
      "id": "a1086f33-fda6-458a-b458-14e15064ddaa",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -1152
      ],
      "parameters": {
        "width": 2192,
        "height": 544,
        "content": "# TELEGRAM CHAT"
      }
    },
    {
      "id": "b94c09c3-6451-4a5e-a85b-1aa497571d4e",
      "name": "Send Refusal Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -864,
        -768
      ]
    },
    {
      "id": "909b0739-2bb6-4ab3-ad66-a5006b1cbf62",
      "name": "Simple Memory2",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        400,
        -1904
      ]
    },
    {
      "id": "885d7ab7-769c-482f-9ccb-b5351bddd428",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        80,
        -2256
      ]
    },
    {
      "id": "14619b70-8499-49dc-9a0d-0c61e62b3ea5",
      "name": "If Text Message Received",
      "type": "n8n-nodes-base.if",
      "position": [
        -1216,
        -1072
      ]
    },
    {
      "id": "ad652cab-041e-445d-9f60-8feacba30c18",
      "name": "If PDF File Received",
      "type": "n8n-nodes-base.if",
      "position": [
        -1040,
        -848
      ]
    },
    {
      "id": "ff0b610a-5a35-4602-9df7-f40fe58d7c3a",
      "name": "Send Downloaded PDF File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        -1008
      ]
    },
    {
      "id": "5c5d0290-6975-4bab-bd36-34c51b43c3b6",
      "name": "Download PDF File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -512,
        -1008
      ]
    },
    {
      "id": "f8ed9971-bea3-422b-a724-3bf66f7fc1ce",
      "name": "Approve Ingestion",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -864,
        -928
      ]
    },
    {
      "id": "adda50a8-624a-4dde-ba84-478ae3e5fbfd",
      "name": "If User Approved",
      "type": "n8n-nodes-base.if",
      "position": [
        -688,
        -928
      ]
    },
    {
      "id": "3448fda2-4133-475d-97c4-683ab18e7e8d",
      "name": "User Dissapproved",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -512,
        -848
      ]
    },
    {
      "id": "a040371b-5896-4d2c-b80a-0614e3d6093c",
      "name": "Send Finished Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -112,
        -1008
      ]
    },
    {
      "id": "b172fc47-6784-4c5d-841c-d3f0b52b059c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2112,
        -2336
      ],
      "parameters": {
        "width": 576,
        "height": 1040,
        "content": "# Credentials\nThis workflow requires 5 different credential configurations to connect with external services. Set up each credential in n8n's credential manager before activating the workflow.\n1. Azur"
      }
    },
    {
      "id": "da165d33-406b-4bce-b521-040e97c4c4e7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -2336
      ],
      "parameters": {
        "width": 688,
        "height": 1376,
        "content": "# Start Using This Workflow\n\n## Quick Setup (5 minutes)\n\n### 1. Update Your URLs\n- Open **Send PDF File** and **Send Downloaded PDF File** nodes\n- Replace `https://your_n8n_instance_url/webhook/ingest"
      }
    }
  ],
  "connections": {
    "AI Agent2": {
      "main": [
        [
          {
            "node": "Send a Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Ingestion": {
      "main": [
        [
          {
            "node": "List All File Names",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send PDF File": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory2": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Token Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Download Corresponding File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If User Approved": {
      "main": [
        [
          {
            "node": "Download PDF File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "User Dissapproved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If Text Message Received",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approve Ingestion": {
      "main": [
        [
          {
            "node": "If User Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download PDF File": {
      "main": [
        [
          {
            "node": "Send Downloaded PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Ingest Webhook": {
      "main": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "List All File Names": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If PDF File Received": {
      "main": [
        [
          {
            "node": "Approve Ingestion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Refusal Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres PGVector Store": {
      "main": [
        []
      ]
    },
    "Azure OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Mistral Cloud": {
      "ai_embedding": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "If Text Message Received": {
      "main": [
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If PDF File Received",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres PGVector Store2": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Postgres PGVector Store3": {
      "ai_tool": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send Downloaded PDF File": {
      "main": [
        [
          {
            "node": "Send Finished Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Mistral Cloud2": {
      "ai_embedding": [
        [
          {
            "node": "Postgres PGVector Store2",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Mistral Cloud3": {
      "ai_embedding": [
        [
          {
            "node": "Postgres PGVector Store3",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Download Corresponding File": {
      "main": [
        [
          {
            "node": "Send PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}