{
  "name": "Process multiple media files in Telegram with Gemini AI & PostgreSQL database",
  "nodes": [
    {
      "id": "e5e130c1-f878-4735-9eec-32c44850113e",
      "name": "Download Voice Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        1072
      ]
    },
    {
      "id": "1794a6d4-7786-4c18-997e-8ba8d7dc71f0",
      "name": "Send a text message1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4272,
        688
      ]
    },
    {
      "id": "98403909-001a-4d05-a889-6fde41ec3a34",
      "name": "Input Message Router1",
      "type": "n8n-nodes-base.switch",
      "position": [
        784,
        1296
      ]
    },
    {
      "id": "ea9a62b2-02ed-452a-a61d-31bbcb73251e",
      "name": "Media_group?2",
      "type": "n8n-nodes-base.if",
      "position": [
        2448,
        1376
      ]
    },
    {
      "id": "b250bfa7-4440-453c-9b31-b0d5dfb85c87",
      "name": "Captions?1",
      "type": "n8n-nodes-base.if",
      "position": [
        2272,
        1520
      ]
    },
    {
      "id": "c92646c7-1197-4400-8ce4-7f4ba3cf4778",
      "name": "Media_group?3",
      "type": "n8n-nodes-base.if",
      "position": [
        2448,
        1648
      ]
    },
    {
      "id": "d7dc3a19-3181-4d8d-a9e9-d9cb7671a078",
      "name": "Insert documents in media_group",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2656,
        1280
      ]
    },
    {
      "id": "56551a78-93f0-41a4-9221-f416e0b4edb8",
      "name": "Insert documents in media_group1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2656,
        1600
      ]
    },
    {
      "id": "3ecb2c02-5396-4684-aaa2-311102bb4b40",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2832,
        1600
      ]
    },
    {
      "id": "b470a0df-94ea-4902-9093-f0ea75afbfd9",
      "name": "Insert media_queue with captions (Trigger)",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2832,
        1280
      ]
    },
    {
      "id": "d11e1a56-ea08-45b9-b8c5-eba27335afce",
      "name": "Insert media_queue (Trigger)",
      "type": "n8n-nodes-base.postgres",
      "position": [
        3008,
        1600
      ]
    },
    {
      "id": "677b9052-c0ff-4932-b297-2431bf8ac790",
      "name": "Get_file_and_captions",
      "type": "n8n-nodes-base.set",
      "position": [
        2656,
        1440
      ]
    },
    {
      "id": "8bb84948-0f83-4c35-8cdd-23f941a12c5d",
      "name": "get_message (text)",
      "type": "n8n-nodes-base.set",
      "position": [
        1152,
        928
      ]
    },
    {
      "id": "3d4e1e9c-0da6-4909-b619-efa2fd792823",
      "name": "Get_only_file",
      "type": "n8n-nodes-base.set",
      "position": [
        2656,
        1760
      ]
    },
    {
      "id": "867ac0ea-68e0-4488-95ae-a35a300425f8",
      "name": "unified_variables",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        704
      ]
    },
    {
      "id": "ee085f92-a654-49f0-8a5a-12062990a06e",
      "name": "Wait for all the files",
      "type": "n8n-nodes-base.wait",
      "position": [
        960,
        704
      ]
    },
    {
      "id": "f09d722b-ff26-40e1-af52-af1fd6830fcf",
      "name": "Get all files from group_id",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1152,
        704
      ]
    },
    {
      "id": "4342c43b-9955-485a-868c-3c295753f3ed",
      "name": "Media_queue Trigger",
      "type": "n8n-nodes-base.postgresTrigger",
      "position": [
        624,
        704
      ]
    },
    {
      "id": "576c4eec-6ecc-423e-aea0-5073d16b0f3c",
      "name": "get_chat_id",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        704
      ]
    },
    {
      "id": "308554ed-f7b6-401e-8ce3-b5088983113a",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        624,
        464
      ]
    },
    {
      "id": "5264db65-e580-424f-873f-cf86ad8d3ea1",
      "name": " Create Tables",
      "type": "n8n-nodes-base.postgres",
      "position": [
        800,
        464
      ]
    },
    {
      "id": "be09c45d-5ccc-476f-a5dd-e0cdc845a991",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3776,
        688
      ]
    },
    {
      "id": "8d4c4fef-65c5-435d-9323-c2e147c6e988",
      "name": "Group Similar Documents",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        2864
      ]
    },
    {
      "id": "fb212505-00b8-404c-9e67-ddbc76e7e4a9",
      "name": "Download CSV",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        2048
      ]
    },
    {
      "id": "6e8b91fe-6c28-4985-9e78-47b68d47241b",
      "name": "Extract from CSV",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        2048
      ]
    },
    {
      "id": "70f975fb-af9e-470b-881e-55e4ce0b9082",
      "name": "Download HTML",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        2192
      ]
    },
    {
      "id": "8fe52c9c-8c5c-4f81-9270-823c04725a27",
      "name": "Download ICS",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        2336
      ]
    },
    {
      "id": "f6c1b259-af21-4064-902e-314e098004ea",
      "name": "Extract from ICS",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        2336
      ]
    },
    {
      "id": "f87ed880-11cb-45c3-a71d-fdfe82b05182",
      "name": "Download JSON",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        2480
      ]
    },
    {
      "id": "374f5c82-6805-4598-b457-18da43993a98",
      "name": "Extract from JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        2480
      ]
    },
    {
      "id": "aa6ef83f-6677-41aa-b31c-45c3b230751b",
      "name": "Download ODS",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        2624
      ]
    },
    {
      "id": "fdabc74a-b7de-4983-b167-45789f3c91f7",
      "name": "Extract from ODS",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        2624
      ]
    },
    {
      "id": "f2c10e5f-981f-4b33-90ff-d704bd5c7468",
      "name": "Download PDF",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        2864
      ]
    },
    {
      "id": "db4dbec4-277c-418f-9004-1df41ec5bc4b",
      "name": "Extract from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        2784
      ]
    },
    {
      "id": "3cb41827-1371-47bd-9b91-02b0107e74cf",
      "name": "Download RTF",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        3088
      ]
    },
    {
      "id": "b33eb4c9-3383-42a3-ba4a-072159a3ca05",
      "name": "Extract from RTF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        3088
      ]
    },
    {
      "id": "f6360fa9-c7ba-47fe-96d3-b82ed0bd7677",
      "name": "Download TEXT FILE",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        3232
      ]
    },
    {
      "id": "d42e06fd-96b0-4da9-b184-0cd5ad272f89",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        3232
      ]
    },
    {
      "id": "93b621d8-c89d-4146-9720-e5bf915d6d16",
      "name": "Download XML",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        3376
      ]
    },
    {
      "id": "ec9fe0a6-4cea-44fc-b015-3c1f4b062f54",
      "name": "Download XLSX",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        3520
      ]
    },
    {
      "id": "e428d4bd-d245-48b8-ab27-cb54da205648",
      "name": "Extract from XLSX",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        3520
      ]
    },
    {
      "id": "3ba98218-91b5-4ef0-94e7-0b97e0d0ae1c",
      "name": "Download IMAGE",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        1376
      ]
    },
    {
      "id": "cf214ecc-3e6f-48dd-81ab-dc97a7dc05a2",
      "name": "Download AUDIO",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        1520
      ]
    },
    {
      "id": "cde94c9a-2c32-48c1-bdf7-ab55e8ae832e",
      "name": "Download VIDEO",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        1664
      ]
    },
    {
      "id": "d8f3d7ab-fd41-4e36-a5e7-ca9c8b5a9a44",
      "name": "Analyze image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1488,
        1376
      ]
    },
    {
      "id": "aeef3459-38fe-4cd9-a40a-d095458749af",
      "name": "Analyze video",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1488,
        1664
      ]
    },
    {
      "id": "aa609f5a-5e32-43da-ae5e-515c5ed2f623",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3728,
        896
      ]
    },
    {
      "id": "4a04372a-5692-4aa3-87b6-2dfc9d8fb08d",
      "name": "Analyze voice message",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1488,
        1072
      ]
    },
    {
      "id": "d49d1079-647a-4b33-bb0a-8107a20050d7",
      "name": "Analyze audio",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1488,
        1520
      ]
    },
    {
      "id": "46f16729-e657-4881-9015-22c5ac360a3b",
      "name": "Fix mime4",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        1664
      ]
    },
    {
      "id": "33c6839c-94bf-41bb-9909-a2fb05e3ff92",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        784,
        2720
      ]
    },
    {
      "id": "64571ee7-fa6b-4958-bfd9-691e0a3e3b1e",
      "name": "Download VIDEO NOTE",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1152,
        1232
      ]
    },
    {
      "id": "1b60699d-d557-4ca0-bb24-d265c7cf882f",
      "name": "Analyze video note",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1488,
        1232
      ]
    },
    {
      "id": "5f171482-a612-44cb-97cf-34f1b30500f6",
      "name": "get_message (Audio/Video message)",
      "type": "n8n-nodes-base.set",
      "position": [
        1840,
        1152
      ]
    },
    {
      "id": "45d9e266-5ad8-453a-a9f4-53f9fb9de398",
      "name": "get_message (Media  message)",
      "type": "n8n-nodes-base.set",
      "position": [
        1824,
        1520
      ]
    },
    {
      "id": "fabc6b75-005f-40ec-9b90-5e4c8b6dd1b9",
      "name": "get_message (File message)",
      "type": "n8n-nodes-base.set",
      "position": [
        2096,
        2832
      ]
    },
    {
      "id": "1f04d9f3-a18d-4b53-a5e2-aca53dcaa75d",
      "name": "Typing…",
      "type": "n8n-nodes-base.telegram",
      "position": [
        784,
        1152
      ]
    },
    {
      "id": "4d611ff9-41b4-4bd4-88b0-766de47917d7",
      "name": "Fix mime",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        1072
      ]
    },
    {
      "id": "526cc0f5-44c3-49fd-8329-4dff738ba559",
      "name": "Fix mime1",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        1232
      ]
    },
    {
      "id": "fcad24fc-4fcf-44d0-ad23-d64d5011b501",
      "name": "Fix mime5",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        1376
      ]
    },
    {
      "id": "f4ca8e31-3633-467b-91a5-e2a5392f21cf",
      "name": "Fix mime6",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        1520
      ]
    },
    {
      "id": "a5b92bec-7efe-4f84-a66a-99a55dbbe004",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1488,
        2048
      ]
    },
    {
      "id": "2949390a-4c7c-4365-866a-cf62b4a53e44",
      "name": "get_error_message",
      "type": "n8n-nodes-base.set",
      "position": [
        1152,
        3680
      ]
    },
    {
      "id": "871e5208-a75e-43fb-b8a8-37f273c98e1d",
      "name": "HTML Extract Generic1",
      "type": "n8n-nodes-base.html",
      "position": [
        1312,
        2192
      ]
    },
    {
      "id": "de565ee9-fa30-44fa-bd35-857f0afbfc68",
      "name": "Get ODS data",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        2624
      ]
    },
    {
      "id": "15ee6585-6522-4b67-bda9-2559df332c9b",
      "name": "Normalize ODS",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        2624
      ]
    },
    {
      "id": "0ca2903f-ed9a-4719-904a-5440308cf2fa",
      "name": "Normalize CSV",
      "type": "n8n-nodes-base.set",
      "position": [
        1680,
        2048
      ]
    },
    {
      "id": "b0d1b577-f629-4ca0-8901-ce36e5b40725",
      "name": "Normalize HTML",
      "type": "n8n-nodes-base.set",
      "position": [
        1488,
        2192
      ]
    },
    {
      "id": "03a4cf03-2b5d-4c08-af76-234d2634fcdd",
      "name": "Normalize ICS",
      "type": "n8n-nodes-base.set",
      "position": [
        1488,
        2336
      ]
    },
    {
      "id": "2f688c04-4c5c-4867-a51c-ef8943ea9fda",
      "name": "Normalize JSON",
      "type": "n8n-nodes-base.set",
      "position": [
        1488,
        2480
      ]
    },
    {
      "id": "22ddea54-677d-40af-b5e2-20bbeb71e855",
      "name": "Normalize PDF",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        2768
      ]
    },
    {
      "id": "f04cbce9-7fe1-49f4-b4ab-2ea74945dc33",
      "name": "Normalize RTF",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        3088
      ]
    },
    {
      "id": "25d4c36c-fd18-49c4-ba40-e22fc94b453e",
      "name": "Normalize text file",
      "type": "n8n-nodes-base.set",
      "position": [
        1488,
        3232
      ]
    },
    {
      "id": "8feb8c65-d387-4884-969b-6383fd4e8d79",
      "name": "Normalize XML",
      "type": "n8n-nodes-base.set",
      "position": [
        1488,
        3376
      ]
    },
    {
      "id": "958a33e1-d47f-4816-a54b-be858b4f00f3",
      "name": "Extract from XML",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1312,
        3376
      ]
    },
    {
      "id": "9df948f1-a227-4540-88c0-df46c5ce7827",
      "name": "Normalize XLSX",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        3520
      ]
    },
    {
      "id": "c26a73c4-b640-46fd-ba5e-0ec06e5d4307",
      "name": "Get RTF data",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        3088
      ]
    },
    {
      "id": "6a048820-a060-4b41-a2bf-1e562a44ef1c",
      "name": "Get RTF data1",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        3520
      ]
    },
    {
      "id": "2d6893e4-9246-4400-8f69-bb5c43102e68",
      "name": "get_error_message1",
      "type": "n8n-nodes-base.set",
      "position": [
        1152,
        1808
      ]
    },
    {
      "id": "3e2c460b-1857-49b9-9c0d-4bc4ad136c16",
      "name": "Text?",
      "type": "n8n-nodes-base.if",
      "position": [
        1488,
        2784
      ]
    },
    {
      "id": "edf7c18c-129a-4b04-835b-defd44e8881e",
      "name": "Analyze document",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1488,
        2928
      ]
    },
    {
      "id": "9963ed16-9670-4251-ac40-bd15028f1c90",
      "name": "Normalize PDF (AI)",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        2928
      ]
    },
    {
      "id": "8fba0cb4-c570-40d9-9fbe-8bf26d7e135f",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1312,
        2928
      ]
    },
    {
      "id": "eb035564-b961-409d-b85a-05eaa146cb2d",
      "name": "MarkdownV2",
      "type": "n8n-nodes-base.code",
      "position": [
        4080,
        688
      ]
    },
    {
      "id": "1f1a460c-799d-467b-8828-a66aa35dc5c6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        2048
      ],
      "parameters": {
        "width": 1728,
        "height": 1872,
        "content": ""
      }
    },
    {
      "id": "c7430169-29d7-44ea-add4-d700fcbe1461",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3504,
        576
      ],
      "parameters": {
        "width": 960,
        "height": 496,
        "content": ""
      }
    },
    {
      "id": "0c756596-0293-4546-be6b-3b9df80c912b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        400
      ],
      "parameters": {
        "width": 576,
        "height": 240,
        "content": ""
      }
    },
    {
      "id": "4a069636-fb37-4f6e-86c3-521d226db569",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        656
      ],
      "parameters": {
        "width": 1360,
        "height": 208,
        "content": ""
      }
    },
    {
      "id": "5d49d6eb-b33b-460b-8dab-a4947624b2e2",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        912
      ],
      "parameters": {
        "width": 1504,
        "height": 1104,
        "content": ""
      }
    },
    {
      "id": "6319463a-4c9e-4cb8-a358-52f760cd6a60",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2208,
        1200
      ],
      "parameters": {
        "width": 1104,
        "height": 752,
        "content": ""
      }
    },
    {
      "id": "32619245-df37-4e49-9ebd-656bfd425d83",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        3872,
        896
      ]
    },
    {
      "id": "fb53fc4f-0961-43bf-bb87-cce3a617a631",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        64
      ],
      "parameters": {
        "width": 608,
        "height": 528,
        "content": "### Gray Section – Database Setup\n\nThis section creates the PostgreSQL tables required for the workflow to function.\n\n**Tables:**\n1. **media_group** – Stores descriptions of files that belong to the s"
      }
    },
    {
      "id": "f9eba4d1-8022-4d51-92d6-e91f6c983a3b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        656
      ],
      "parameters": {
        "width": 608,
        "height": 448,
        "content": "### Green Section – Media Queue Trigger\n\nThis section listens for updates in the `media_queue` table.\n\n**Process:**\n1. The trigger checks regularly for new entries in `media_queue`.\n2. When new data i"
      }
    },
    {
      "id": "3d8a9609-f652-453c-9b60-e63eec5c8223",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        1280
      ],
      "parameters": {
        "width": 608,
        "height": 528,
        "content": "### Blue Section – Telegram Trigger & Message Type Handling\n\nTriggered when a new message is received on Telegram.\n\n**Flow:**\n1. Sends a \"typing\" action to Telegram.\n2. Detects message type:\n   - **Te"
      }
    },
    {
      "id": "dcaae51c-ffa4-4250-9709-161295c0191d",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        2048
      ],
      "parameters": {
        "width": 608,
        "height": 496,
        "content": "### Red Section – Document Processing\n\nProcesses supported document types: `CSV, HTML, ICS, JSON, ODS, PDF, RTF, TXT, XML, Spreadsheet`.\n\n**Steps:**\n1. Download the file.\n2. Extract data (file name, f"
      }
    },
    {
      "id": "088dcb99-8eec-4d6d-9cf5-5c6e859ac527",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2448,
        2000
      ],
      "parameters": {
        "width": 608,
        "height": 576,
        "content": "### Yellow Section – File & Caption Handling\n\nDetermines how files are stored and processed based on presence of `captions` and `media_group_id`.\n\n**Cases:**\n1. **Captions + Media Group**  \n   - First"
      }
    },
    {
      "id": "615b4bf9-05ae-4131-9200-eae91729400a",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3504,
        1136
      ],
      "parameters": {
        "width": 608,
        "height": 496,
        "content": "### Purple Section – AI Agent & Output Formatting\n\nThis section contains the AI Agent connected to:\n- PostgreSQL chat memory (replaceable with any memory type)\n- AI model of choice (replaceable)\n\n**No"
      }
    },
    {
      "id": "8da02301-1c6d-4092-b86b-d378c1afae48",
      "name": "Get_message (multiple files)",
      "type": "n8n-nodes-base.set",
      "position": [
        1488,
        704
      ]
    },
    {
      "id": "fad74af7-1f60-474c-87fe-0c15823ed829",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        144
      ],
      "parameters": {
        "width": 448,
        "height": 176,
        "content": "**🙏 Special Thanks**\n\nA huge thank you to **Ezema Gingsley Chibuzo** for the inspiration of the first version of this workflow:  \n[Create a Multi-Modal Telegram Support Bot with GPT-4 and Supabase RAG"
      }
    },
    {
      "id": "5c245033-1efe-43c4-961a-df92eb3792f5",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        608,
        1392
      ]
    },
    {
      "id": "ab44181a-1610-4c41-8b09-a123b6675491",
      "name": "Normalize input",
      "type": "n8n-nodes-base.set",
      "position": [
        3584,
        688
      ]
    },
    {
      "id": "b7486e58-b419-44f4-9229-e8118514f69a",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4496,
        832
      ],
      "parameters": {
        "width": 352,
        "height": 224,
        "content": "---\n\n## 💡 Need Assistance?\n\nIf you’d like help customizing or extending this workflow, feel free to reach out:  \n\n📧 Email: [johnsilva11031@gmail.com](mailto:johnsilva11031@gmail.com)  \n🔗 LinkedIn: [Jo"
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Insert media_queue (Trigger)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Analyze document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text?": {
      "main": [
        [
          {
            "node": "Normalize PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Download CSV",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download HTML",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download ICS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download JSON",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download ODS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download RTF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download TEXT FILE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download XML",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download XLSX",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get_error_message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mime": {
      "main": [
        [
          {
            "node": "Analyze voice message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "MarkdownV2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Normalize CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mime1": {
      "main": [
        [
          {
            "node": "Analyze video note",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mime4": {
      "main": [
        [
          {
            "node": "Analyze video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mime5": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mime6": {
      "main": [
        [
          {
            "node": "Analyze audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Captions?1": {
      "main": [
        [
          {
            "node": "Media_group?2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Media_group?3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MarkdownV2": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_chat_id": {
      "main": [
        [
          {
            "node": "Wait for all the files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download CSV": {
      "main": [
        [
          {
            "node": "Extract from CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download ICS": {
      "main": [
        [
          {
            "node": "Extract from ICS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download ODS": {
      "main": [
        [
          {
            "node": "Extract from ODS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download PDF": {
      "main": [
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Download RTF": {
      "main": [
        [
          {
            "node": "Extract from RTF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download XML": {
      "main": [
        [
          {
            "node": "Extract from XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get ODS data": {
      "main": [
        [
          {
            "node": "Normalize ODS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get RTF data": {
      "main": [
        [
          {
            "node": "Normalize RTF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze audio": {
      "main": [
        [
          {
            "node": "get_message (Media  message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "get_message (Media  message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze video": {
      "main": [
        [
          {
            "node": "get_message (Media  message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download HTML": {
      "main": [
        [
          {
            "node": "HTML Extract Generic1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download JSON": {
      "main": [
        [
          {
            "node": "Extract from JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download XLSX": {
      "main": [
        [
          {
            "node": "Extract from XLSX",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get RTF data1": {
      "main": [
        [
          {
            "node": "Normalize XLSX",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get_only_file": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Media_group?2": {
      "main": [
        [
          {
            "node": "Insert documents in media_group",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get_file_and_captions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Media_group?3": {
      "main": [
        [
          {
            "node": "Insert documents in media_group1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get_only_file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize CSV": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize ICS": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize ODS": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize PDF": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize RTF": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize XML": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download AUDIO": {
      "main": [
        [
          {
            "node": "Fix mime6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download IMAGE": {
      "main": [
        [
          {
            "node": "Fix mime5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download VIDEO": {
      "main": [
        [
          {
            "node": "Fix mime4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize HTML": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize JSON": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize XLSX": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize input": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze document": {
      "main": [
        [
          {
            "node": "Normalize PDF (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from CSV": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from ICS": {
      "main": [
        [
          {
            "node": "Normalize ICS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from ODS": {
      "main": [
        [
          {
            "node": "Get ODS data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Text?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from RTF": {
      "main": [
        [
          {
            "node": "Get RTF data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XML": {
      "main": [
        [
          {
            "node": "Normalize XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Input Message Router1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Normalize text file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from JSON": {
      "main": [
        [
          {
            "node": "Normalize JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XLSX": {
      "main": [
        [
          {
            "node": "Get RTF data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_error_message": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "unified_variables": {
      "main": [
        [
          {
            "node": "Get_message (multiple files)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze video note": {
      "main": [
        [
          {
            "node": "get_message (Audio/Video message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download TEXT FILE": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize PDF (AI)": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_error_message1": {
      "main": [
        [
          {
            "node": "get_message (Media  message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_message (text)": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download VIDEO NOTE": {
      "main": [
        [
          {
            "node": "Fix mime1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Media_queue Trigger": {
      "main": [
        [
          {
            "node": "get_chat_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize text file": {
      "main": [
        [
          {
            "node": "get_message (File message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Analyze voice message": {
      "main": [
        [
          {
            "node": "get_message (Audio/Video message)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get_file_and_captions": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML Extract Generic1": {
      "main": [
        [
          {
            "node": "Normalize HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Message Router1": {
      "main": [
        [
          {
            "node": "get_message (text)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Voice Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download VIDEO NOTE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download IMAGE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download AUDIO",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download VIDEO",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Group Similar Documents",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get_error_message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Voice Message": {
      "main": [
        [
          {
            "node": "Fix mime",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for all the files": {
      "main": [
        [
          {
            "node": "Get all files from group_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group Similar Documents": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "get_message (File message)": {
      "main": [
        [
          {
            "node": "Captions?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all files from group_id": {
      "main": [
        [
          {
            "node": "unified_variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get_message (multiple files)": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_message (Media  message)": {
      "main": [
        [
          {
            "node": "Captions?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert documents in media_group": {
      "main": [
        [
          {
            "node": "Insert media_queue with captions (Trigger)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert documents in media_group1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_message (Audio/Video message)": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": " Create Tables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}