AutomationFlowsAI & RAG › Extract Invoice Data to Excel Using Google Gemini, Ocr, and Telegram

Extract Invoice Data to Excel Using Google Gemini, Ocr, and Telegram

ByRamdoni @ramdoni on n8n.io

This workflow automatically extracts structured data from invoices sent via Telegram (PDF or image) and saves it to Excel. A user sends an invoice (PDF or image) to a Telegram bot The workflow detects the file type (PDF or image) For PDF: Extracts text directly from the file…

Event trigger★★★★★ complexityAI-powered34 nodesTelegram TriggerTelegramN8N Nodes TesseractjsMicrosoft ExcelGoogle Gemini
AI & RAG Trigger: Event Nodes: 34 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #15174 — we link there as the canonical source.

This workflow follows the Googlegemini → Telegram recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "ZrI8tdkxYodPkCt6",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Extract Data from Invoices to Excel using AI + OCR (PDF/Image)",
  "tags": [],
  "nodes": [
    {
      "id": "b8a4c4c7-c47f-42bd-bff3-a0036cf960c1",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -96,
        32
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "3669271f-ceb0-4685-81f2-464dbcbc96bc",
      "name": "Detect File Type",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        32
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "686740fb-7c5b-4dcf-8575-ec6b5a98b2ee",
      "name": "Notifikasi file invalid",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        448
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "6471cc50-9980-435a-99a6-90588d16a140",
      "name": "Mapping PDF",
      "type": "n8n-nodes-base.set",
      "position": [
        320,
        384
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "db1cc9db-105f-4872-9e58-4d5a9a1dffe2",
      "name": "Mapping Image",
      "type": "n8n-nodes-base.set",
      "position": [
        320,
        720
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "f249898a-61c7-49f6-8802-ee40021e530a",
      "name": "Get Image",
      "type": "n8n-nodes-base.telegram",
      "position": [
        528,
        720
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "03d96845-35f2-42b2-b82e-70674c972707",
      "name": "Get PDF",
      "type": "n8n-nodes-base.telegram",
      "position": [
        528,
        384
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "270e13f4-ca09-4d2f-91ba-92f2f4daf19b",
      "name": "Notifikasi file sedang diproses",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        272
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "87a251f9-6c9e-41e5-bd6d-85fb96ef6a80",
      "name": "Clean PDF Text",
      "type": "n8n-nodes-base.code",
      "position": [
        976,
        384
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "db53dd4d-8816-47d3-881e-6925d59684fd",
      "name": "Clean OCR Text",
      "type": "n8n-nodes-base.code",
      "position": [
        976,
        720
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "b06374f7-6b56-4388-b0bf-b9a3c3ccd0e6",
      "name": "Route by File Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -272,
        400
      ],
      "parameters": {},
      "typeVersion": 3.3
    },
    {
      "id": "f78b903d-f3ba-4bef-a0ff-73862130e442",
      "name": "Extract PDF Text",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        752,
        384
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "7b900e78-bc5a-490e-8abf-af20ad43ae24",
      "name": "Prepare PDF Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1200,
        384
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "90ab039c-fe7e-49b6-adb5-837e9b66f55d",
      "name": "Extract Text from Image (OCR)",
      "type": "n8n-nodes-tesseractjs.tesseractNode",
      "position": [
        736,
        720
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0b7d7792-14e6-493a-b443-4230461e4e00",
      "name": "Prepare Image Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1200,
        720
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "a58eb524-03c5-403f-ad75-7ea655bdc4a5",
      "name": "Parse AI Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2080,
        528
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "d18ebac0-e6e8-4b04-8a3c-4a39f88a5ed5",
      "name": "Validate Extracted Data",
      "type": "n8n-nodes-base.code",
      "position": [
        2288,
        528
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "7015fc32-1278-4e0d-b77b-81898dc0153b",
      "name": "Check Data Validity",
      "type": "n8n-nodes-base.if",
      "position": [
        2496,
        528
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "8104ecbc-d823-41c7-a3f4-a0569a16ba7a",
      "name": "Format Data for Excel",
      "type": "n8n-nodes-base.code",
      "position": [
        2704,
        432
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "b888987a-c967-48a7-a584-323eeb26f686",
      "name": "Save Data to Excel",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        3008,
        432
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "d7e254c2-3750-4374-b701-db8a4561ad69",
      "name": "Send Success Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3344,
        432
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "0a5e4248-67e3-45b6-bd98-4013e9de3495",
      "name": "Send Invalid Data Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2704,
        624
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "24d376c0-9006-4a92-9fdb-ee4d88aac28b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        -400
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "cccd632a-c083-450c-a8bf-0f75df76f5c8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -64
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "3617258f-c413-44bd-8c68-a20d1479ac04",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -64
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "8466f148-23b0-433d-b3a0-bf3d4992bb1d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        272
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "ccfaf65d-098f-4005-9952-f9f765e16268",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        256
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "ea672620-2451-431b-bedf-9f4b065bf6e3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        592
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "17b6debe-b2ae-4d7f-a29b-6cf33e65f767",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        400
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "123890e8-0a75-47b9-a1a9-f58736514722",
      "name": "Extract Structured Data (AI)",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1456,
        528
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9b4d23b8-f896-4301-bcd0-3e67dd895b95",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2048,
        400
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a60bcefb-2816-483c-ad5c-8bbeefd60f7d",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2896,
        304
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "76bbe2c7-0b9f-4c0e-9149-dee81b456c0a",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3248,
        304
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "6172ad02-ebcc-467e-ad0e-17719df3b28c",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -400
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cad83add-b0ad-4f2e-a762-e721d9d4d6c8",
  "connections": {
    "Get PDF": {
      "main": [
        [
          {
            "node": "Extract PDF Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image": {
      "main": [
        [
          {
            "node": "Extract Text from Image (OCR)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapping PDF": {
      "main": [
        [
          {
            "node": "Get PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapping Image": {
      "main": [
        [
          {
            "node": "Get Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean OCR Text": {
      "main": [
        [
          {
            "node": "Prepare Image Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean PDF Text": {
      "main": [
        [
          {
            "node": "Prepare PDF Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect File Type": {
      "main": [
        [
          {
            "node": "Route by File Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract PDF Text": {
      "main": [
        [
          {
            "node": "Clean PDF Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare PDF Data": {
      "main": [
        [
          {
            "node": "Extract Structured Data (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Detect File Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Validate Extracted Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Image Data": {
      "main": [
        [
          {
            "node": "Extract Structured Data (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by File Type": {
      "main": [
        [
          {
            "node": "Mapping PDF",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notifikasi file sedang diproses",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mapping Image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notifikasi file sedang diproses",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notifikasi file invalid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Data to Excel": {
      "main": [
        [
          {
            "node": "Send Success Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Data Validity": {
      "main": [
        [
          {
            "node": "Format Data for Excel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Invalid Data Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Data for Excel": {
      "main": [
        [
          {
            "node": "Save Data to Excel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Extracted Data": {
      "main": [
        [
          {
            "node": "Check Data Validity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Structured Data (AI)": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from Image (OCR)": {
      "main": [
        [
          {
            "node": "Clean OCR Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automatically extracts structured data from invoices sent via Telegram (PDF or image) and saves it to Excel. A user sends an invoice (PDF or image) to a Telegram bot The workflow detects the file type (PDF or image) For PDF: Extracts text directly from the file…

Source: https://n8n.io/workflows/15174/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Social Media Audio Extractor. Uses telegramTrigger, telegram, openAi, httpRequest. Event-driven trigger; 31 nodes.

Telegram Trigger, Telegram, OpenAI +2
AI & RAG

OCR + AI + Duplicate Protection (n8n Workflow)

Telegram Trigger, Microsoft Excel, OpenAI Chat +3
AI & RAG

This workflow connects Telegram, Google Gemini AI, and Notion to make task creation effortless.

Google Gemini Chat, Telegram Trigger, Information Extractor +2
AI & RAG

Transform your receipt management with this comprehensive n8n workflow that automatically processes receipts through Telegram, extracts transaction data using AI, and stores it across multiple platfor

Telegram Trigger, Telegram, HTTP Request +4
AI & RAG

Flow1. Uses telegram, openAi, telegramTrigger, httpRequest. Event-driven trigger; 10 nodes.

Telegram, OpenAI, Telegram Trigger +1