{
  "name": "Create a searchable document archive with Telegram, Drive, OCR and Airtable",
  "nodes": [
    {
      "id": "b1414d19-9d49-480b-be77-6d8709c86919",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1264,
        272
      ]
    },
    {
      "id": "ae8100e3-c852-48a3-a564-f8d1524439cc",
      "name": "Check if File/Image",
      "type": "n8n-nodes-base.if",
      "position": [
        -1040,
        272
      ]
    },
    {
      "id": "0c28e059-5e63-4107-b8c9-02074ed7b7ca",
      "name": "Sticky: Check File",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        144
      ],
      "parameters": {
        "width": 200,
        "height": 288,
        "content": "🔍 **Filter**: Only proceed if message has file or image"
      }
    },
    {
      "id": "5c25a662-adbc-44cb-a3ef-678aff284c6d",
      "name": "Extract File Metadata",
      "type": "n8n-nodes-base.set",
      "position": [
        -816,
        160
      ]
    },
    {
      "id": "5007396a-0dcf-4c74-ac08-eab12479ef61",
      "name": "Sticky: Extract Metadata",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        0
      ],
      "parameters": {
        "width": 210,
        "height": 304,
        "content": "📋 **Extract**: fileId, name, MIME, chat & user info"
      }
    },
    {
      "id": "79240107-39e4-4185-9cd2-d015b2fd2a39",
      "name": "Download File from Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -608,
        160
      ]
    },
    {
      "id": "76a9187c-768d-40d9-97b0-4e93d2b09e40",
      "name": "Sticky: Download File",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -16
      ],
      "parameters": {
        "width": 220,
        "height": 320,
        "content": "⬇️ **Download**: Get file binary from Telegram API"
      }
    },
    {
      "id": "b1a86b46-e69b-41cb-90b4-8c9bef5e4e59",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -384,
        160
      ]
    },
    {
      "id": "5695fd86-ddd8-40a1-ad2d-90debbc441bb",
      "name": "Sticky: Upload to Drive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        -16
      ],
      "parameters": {
        "width": 220,
        "height": 320,
        "content": "☁️ **Upload**: Save file to Google Drive root"
      }
    },
    {
      "id": "399a6769-627f-40b8-b2ea-c82a8c32eea9",
      "name": "Check if OCR Eligible",
      "type": "n8n-nodes-base.if",
      "position": [
        -160,
        160
      ]
    },
    {
      "id": "4fbd99c5-1138-41e6-ac76-1e37b179330e",
      "name": "Sticky: OCR Eligible",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -16
      ],
      "parameters": {
        "width": 200,
        "height": 320,
        "content": "🧠 **OCR Check**: Is it image or PDF?"
      }
    },
    {
      "id": "c0310c17-5f48-4646-ae7e-6bbef0ef4504",
      "name": "Google Vision OCR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        64,
        64
      ]
    },
    {
      "id": "75dd9b9d-a291-4122-a6cd-98a09dc88fe7",
      "name": "Sticky: Vision OCR",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -80
      ],
      "parameters": {
        "width": 220,
        "height": 320,
        "content": "🔍 **OCR**: Extract text via Google Vision API"
      }
    },
    {
      "id": "352815cf-6eda-4ac2-8e1e-de2f04975c56",
      "name": "Extract OCR Text",
      "type": "n8n-nodes-base.set",
      "position": [
        272,
        64
      ]
    },
    {
      "id": "9ada9e69-ac35-4b83-a028-3f1f3e182cf0",
      "name": "Sticky: Extract OCR Text",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -160
      ],
      "parameters": {
        "width": 220,
        "height": 352,
        "content": "✂️ **Parse**: Get fullTextAnnotation from OCR response"
      }
    },
    {
      "id": "6d4867d7-32ef-4b1a-b219-fbbe4a06b2a0",
      "name": "No OCR Needed",
      "type": "n8n-nodes-base.set",
      "position": [
        64,
        272
      ]
    },
    {
      "id": "e3179bd4-e6d9-4931-8133-d9856a2ddbf2",
      "name": "Sticky: No OCR",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        400
      ],
      "parameters": {
        "width": 200,
        "height": 240,
        "content": "➖ **Skip OCR**: Non-image/PDF files"
      }
    },
    {
      "id": "d4cbfc85-2c1e-4b18-92ce-9d245caefc77",
      "name": "Merge OCR Paths",
      "type": "n8n-nodes-base.merge",
      "position": [
        400,
        160
      ]
    },
    {
      "id": "ba51bc68-77df-4727-9bb3-11febae993cc",
      "name": "Index in Airtable",
      "type": "n8n-nodes-base.airtable",
      "position": [
        624,
        160
      ]
    },
    {
      "id": "838b0f5b-987d-4d35-b03e-e21e71bd8183",
      "name": "Sticky: Airtable Index",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        80
      ],
      "parameters": {
        "width": 230,
        "height": 224,
        "content": "📊 **Index**: Save metadata + OCR text to Airtable"
      }
    },
    {
      "id": "aa68c4ad-3bbc-4d71-b822-7a4eb988eba2",
      "name": "Send Success Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        848,
        160
      ]
    },
    {
      "id": "5a85d261-8535-4024-aa0a-d13508ab68b0",
      "name": "Sticky: Success Msg",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        16
      ],
      "parameters": {
        "width": 220,
        "height": 288,
        "content": "✅ **Notify**: Success message with link & preview"
      }
    },
    {
      "id": "247f8290-8372-41b6-af93-d50004d49a27",
      "name": "Send Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        848,
        368
      ]
    },
    {
      "id": "6c943962-95b5-40c0-8492-daa5a5421bbf",
      "name": "Sticky: Error Msg",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        528
      ],
      "parameters": {
        "width": 200,
        "height": 70,
        "content": "❌ **Error**: Notify user on failure"
      }
    },
    {
      "id": "d645926d-5289-4878-b6fd-12d6e7b0490b",
      "name": "Check Search Command",
      "type": "n8n-nodes-base.if",
      "position": [
        -816,
        464
      ]
    },
    {
      "id": "9328c7e3-6c2b-4d0c-897f-0cbf92c61ce8",
      "name": "Sticky: Search Cmd",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        592
      ],
      "parameters": {
        "width": 200,
        "height": 70,
        "content": "🔎 **Detect**: /search <query> command"
      }
    },
    {
      "id": "56783c48-c377-4415-90b2-66f6793196ef",
      "name": "Extract Search Query",
      "type": "n8n-nodes-base.set",
      "position": [
        -608,
        464
      ]
    },
    {
      "id": "6da1bc77-fe2b-4d7d-af2f-96956d2ada79",
      "name": "Sticky: Extract Query",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        592
      ],
      "parameters": {
        "width": 210,
        "height": 70,
        "content": "✂️ **Parse**: Extract query after /search"
      }
    },
    {
      "id": "2a8429f9-89fe-4387-872d-fb6bc4702eac",
      "name": "Search in Index",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -384,
        464
      ]
    },
    {
      "id": "e82131ab-bb70-41d1-a904-d0d088fb3c53",
      "name": "Sticky: Search Index",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        384
      ],
      "parameters": {
        "width": 230,
        "height": 70,
        "content": "🔍 **Search**: Airtable full-text in extracted_text"
      }
    },
    {
      "id": "81969e62-0c4b-43e4-ab04-d6d4c9978f7c",
      "name": "Send Search Results",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -160,
        464
      ]
    },
    {
      "id": "d7cafa5b-c77f-4cc7-bc80-36491aa20d4e",
      "name": "Sticky: Search Results",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        384
      ],
      "parameters": {
        "width": 220,
        "height": 70,
        "content": "📋 **Results**: Send matched files with previews"
      }
    },
    {
      "id": "3896a4e4-efa1-42af-af9b-d1954ac06471",
      "name": "Sticky: Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        192
      ],
      "parameters": {
        "width": 220,
        "height": 224,
        "content": "🎯 **Trigger**: Listens for new messages/documents from users"
      }
    }
  ],
  "connections": {
    "No OCR Needed": {
      "main": [
        [
          {
            "node": "Merge OCR Paths",
            "type": "main",
            "index": 1
          },
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge OCR Paths": {
      "main": [
        [
          {
            "node": "Index in Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search in Index": {
      "main": [
        [
          {
            "node": "Send Search Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract OCR Text": {
      "main": [
        [
          {
            "node": "Merge OCR Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check if File/Image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check Search Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Vision OCR": {
      "main": [
        [
          {
            "node": "Extract OCR Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Index in Airtable": {
      "main": [
        [
          {
            "node": "Send Success Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if File/Image": {
      "main": [
        [
          {
            "node": "Extract File Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Search Command": {
      "main": [
        [
          {
            "node": "Extract Search Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Search Query": {
      "main": [
        [
          {
            "node": "Search in Index",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if OCR Eligible": {
      "main": [
        [
          {
            "node": "Google Vision OCR",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No OCR Needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract File Metadata": {
      "main": [
        [
          {
            "node": "Download File from Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Google Drive": {
      "main": [
        [
          {
            "node": "Check if OCR Eligible",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File from Telegram": {
      "main": [
        [
          {
            "node": "Upload to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}