{
  "name": "Create a multi-modal Telegram support bot with GPT-4 and Supabase RAG",
  "nodes": [
    {
      "id": "2bcc338a-d519-42dd-bffd-9b5854b3a456",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        860,
        489.5
      ]
    },
    {
      "id": "ebc22166-b749-42c7-9d91-9fef170c6b65",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3896,
        1156.5
      ]
    },
    {
      "id": "343b5290-d805-4136-a609-b12025df5339",
      "name": "Download Audio",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2840,
        500
      ]
    },
    {
      "id": "8d5bd08c-5b59-4bff-97b1-ffca75262d1b",
      "name": "Translate to Text",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        3060,
        500
      ]
    },
    {
      "id": "3def7806-cf50-4fc8-a2c6-ea966cd0bd4e",
      "name": "Download PDF",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        1050
      ]
    },
    {
      "id": "29624835-cc63-489f-8913-ece65ecf46f2",
      "name": "Download Image",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2180,
        1250
      ]
    },
    {
      "id": "11755226-785d-4719-9d75-d82518ed615b",
      "name": "Fix mimeType",
      "type": "n8n-nodes-base.code",
      "position": [
        2400,
        1250
      ]
    },
    {
      "id": "2d7fe3f6-d152-4b6d-8184-96f1073c73c6",
      "name": "Download Photo",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2180,
        700
      ]
    },
    {
      "id": "802f819c-9d11-4720-a63f-0d3bada509bf",
      "name": "Fix mimeType1",
      "type": "n8n-nodes-base.code",
      "position": [
        2400,
        700
      ]
    },
    {
      "id": "e245a098-08ba-4cf1-a3aa-3134070016ae",
      "name": "Photo to text",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2620,
        700
      ]
    },
    {
      "id": "74df7c06-f07f-4504-a246-33665d355d70",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1520,
        1350
      ]
    },
    {
      "id": "531826bd-e8ab-4e56-9f56-4e0dd8847c2f",
      "name": "Download Spreadsheet",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        1650
      ]
    },
    {
      "id": "6ffa7f95-c506-40ff-a320-f2b8b35db632",
      "name": "Extract from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        1050
      ]
    },
    {
      "id": "795a57de-78c6-44e8-a89b-a45c354988c9",
      "name": "Extract from Spreadsheet",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        1650
      ]
    },
    {
      "id": "f567e9a4-e043-4431-b574-b217b4fa2656",
      "name": "Typing…",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1080,
        379
      ]
    },
    {
      "id": "67edb91b-880e-4542-88e7-fc7bde727a75",
      "name": "Supported Document File Types",
      "type": "n8n-nodes-base.code",
      "position": [
        1300,
        1350
      ]
    },
    {
      "id": "5c13b643-22c6-49cb-9055-54826f49fd13",
      "name": "Group Similar Documents",
      "type": "n8n-nodes-base.code",
      "position": [
        1740,
        1550
      ]
    },
    {
      "id": "1923a439-9f1c-4df1-9360-a41250e61931",
      "name": "Input Message Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        1080,
        579
      ]
    },
    {
      "id": "510a0800-4323-4372-9f8a-3b3c26d8a455",
      "name": "Document Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        1960,
        1487
      ]
    },
    {
      "id": "8c04ffbb-9a63-4089-8877-c0c668eeabcc",
      "name": "Download JSON",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        1850
      ]
    },
    {
      "id": "06a353d1-1ead-4973-aeff-4991ae2ca29f",
      "name": "Extract from JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        1850
      ]
    },
    {
      "id": "376ab859-3a6a-4f2d-80da-f0ab8c5149f6",
      "name": "Download XML",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        2050
      ]
    },
    {
      "id": "a4c890b7-d858-42aa-9e60-746ce6b6d17b",
      "name": "Extract from XML",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        2050
      ]
    },
    {
      "id": "d91df63b-926b-43f5-9846-14cdde235b8d",
      "name": "Download Word Document",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2180,
        1450
      ]
    },
    {
      "id": "8a4fecf9-c50e-44ce-a4ce-c60713805f71",
      "name": "File to Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2400,
        1450
      ]
    },
    {
      "id": "b40a6b1f-0a8e-4788-ae3a-17138cf5918e",
      "name": "Convert to text (convertapi.com)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2620,
        1450
      ]
    },
    {
      "id": "59fad9e4-dbfc-4f6b-bfad-156b821e78dd",
      "name": "Download Text",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2840,
        1450
      ]
    },
    {
      "id": "914ab0ed-f102-4fa3-9db3-cf097b92c0ec",
      "name": "Photo to text1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2620,
        1250
      ]
    },
    {
      "id": "9f4e250c-fb80-4b96-a9c6-d4fd47382985",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        1280
      ],
      "parameters": {
        "width": 620,
        "height": 260,
        "content": "\n\n## Requirement/Credentials\n1. Google drive API Key\n2. Telegram Bot Token. [Guide](https://docs.n8n.io/integrations/builtin/credentials/telegram/?utm_source=n8n_app&utm_medium=credential_settings&utm"
      }
    },
    {
      "id": "f38669dd-5f21-4bb6-9f4d-1768e629eb0e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        440
      ],
      "parameters": {
        "width": 620,
        "height": 800,
        "content": "## ⚙️ How It Works \n### 🔁 Message Routing\n1. **Telegram Trigger** captures the user message (Text, Image, Voice, Document)\n2. **Message Router** routes input by type using a Switch node\n3. Each type i"
      }
    },
    {
      "id": "ca3a50ef-8148-4bb7-810c-a14422791866",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        860,
        -160
      ]
    },
    {
      "id": "5f8a25d8-a8bb-4b01-a7b0-7ad7d58ab0c9",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1080,
        -160
      ]
    },
    {
      "id": "3020c220-4e42-4c80-8bc8-7b93bc9a56e6",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1420,
        62.5
      ]
    },
    {
      "id": "cc3f97fa-842d-45ae-ac51-6def07bfed1e",
      "name": "Recursive Character Text Splitter1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1508,
        260
      ]
    },
    {
      "id": "c448b82d-7145-4d46-a0e6-f2a01234331f",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        3280,
        1376.5
      ]
    },
    {
      "id": "5c1f5765-6d8e-429d-80d6-c9b3b15d4525",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1300,
        60
      ]
    },
    {
      "id": "0e500c88-38e1-4388-b0ef-116f95cf609c",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3548,
        1576.5
      ]
    },
    {
      "id": "3ecaba71-3c29-42dd-8440-cd5c574241b9",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        3400,
        1376.5
      ]
    },
    {
      "id": "086a122b-ffa3-43d5-9551-a8a9888c4bba",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -140
      ],
      "parameters": {
        "width": 340,
        "height": 220,
        "content": "## ⚙️ Before using the Telegram chatbot:\nManually run this workflow to import your **Knowledge base** from Google drive into **Supabase** with vector embeddings.\nThis enables the Telegram chatbot to a"
      }
    },
    {
      "id": "4d151254-2466-4c9b-9099-16f78cdf939f",
      "name": "Reranker Cohere",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        3668,
        1576.5
      ]
    },
    {
      "id": "744219e9-66ef-45da-8d7c-a216862aca43",
      "name": "Extract Text",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        300
      ]
    },
    {
      "id": "76e0a4d6-8e34-4a87-9809-832c03d22097",
      "name": "Extract Text & Content",
      "type": "n8n-nodes-base.set",
      "position": [
        2840,
        700
      ]
    },
    {
      "id": "c366d6dc-bcf0-4bf8-952e-e4565e198c3a",
      "name": "Extract Error Message",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        850
      ]
    },
    {
      "id": "89aa2812-0952-4ab5-8e3c-63e9ee7b9128",
      "name": "Extract Text1",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1650
      ]
    },
    {
      "id": "5313c3b4-ecc9-47d0-a15d-33b4f7bb1b5b",
      "name": "Extract Text2",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1850
      ]
    },
    {
      "id": "676253d8-dc18-4915-9cff-8081bcb33f63",
      "name": "Extract Text3",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        2050
      ]
    },
    {
      "id": "c3807fa7-c537-4454-a2ac-baa8996d2808",
      "name": "Extract Text4",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1050
      ]
    },
    {
      "id": "428f828e-bef8-425a-90dc-b53ef786216e",
      "name": "Extract Text5",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1450
      ]
    },
    {
      "id": "9fe5eac7-98a4-40d4-8896-5af7ea86a278",
      "name": "Add to Supabase Vector DB",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        1316,
        -160
      ]
    },
    {
      "id": "e080e0a0-053a-4648-87cf-ac322b423280",
      "name": "Knowledge Base AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3312,
        1156.5
      ]
    },
    {
      "id": "d5cf1a5a-a84d-491e-922e-ce1628ab08db",
      "name": "Supabase Vector Store Search",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        3520,
        1379
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Group Similar Documents",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        []
      ]
    },
    "Download PDF": {
      "main": [
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download XML": {
      "main": [
        [
          {
            "node": "Extract from XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mimeType": {
      "main": [
        [
          {
            "node": "Photo to text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download JSON": {
      "main": [
        [
          {
            "node": "Extract from JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Text": {
      "main": [
        [
          {
            "node": "Extract Text5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Add to Supabase Vector DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text1": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text2": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text3": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text4": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text5": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mimeType1": {
      "main": [
        [
          {
            "node": "Photo to text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Photo to text": {
      "main": [
        [
          {
            "node": "Extract Text & Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Audio": {
      "main": [
        [
          {
            "node": "Translate to Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Fix mimeType",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Photo": {
      "main": [
        [
          {
            "node": "Fix mimeType1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File to Base64": {
      "main": [
        [
          {
            "node": "Convert to text (convertapi.com)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Photo to text1": {
      "main": [
        [
          {
            "node": "Extract Text & Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Document Router": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Word Document",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Spreadsheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download JSON",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "Supabase Vector Store Search",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Extract Text4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XML": {
      "main": [
        [
          {
            "node": "Extract Text3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Input Message Router",
            "type": "main",
            "index": 0
          },
          {
            "node": "Typing…",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Add to Supabase Vector DB",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from JSON": {
      "main": [
        [
          {
            "node": "Extract Text2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate to Text": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store Search",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Add to Supabase Vector DB",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Download Spreadsheet": {
      "main": [
        [
          {
            "node": "Extract from Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Message Router": {
      "main": [
        [
          {
            "node": "Extract Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Photo",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Supported Document File Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Extract Error Message": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Word Document": {
      "main": [
        [
          {
            "node": "File to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text & Content": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group Similar Documents": {
      "main": [
        [
          {
            "node": "Document Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Spreadsheet": {
      "main": [
        [
          {
            "node": "Extract Text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store Search": {
      "ai_tool": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Supported Document File Types": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to text (convertapi.com)": {
      "main": [
        [
          {
            "node": "Download Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}