Skip to main content

Extract invoice data to Excel using Google Gemini, OCR, and Telegram

Workflow preview

Workflow preview
100%
Extract invoice data to Excel using Google Gemini, OCR, and Telegram preview
Open on n8n.io

1. Workflow Overview

1. HOW IT WORKS This workflow automatically extracts structured data from invoices sent via Telegram (PDF or image) and saves it to Excel. 1. A user sends an invoice (PDF or image) to a Telegram...

Best for

  • Invoice Processing automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.telegramtrigger, n8n-nodes-base.code, n8n-nodes-base.telegram, n8n-nodes-base.set, n8n-nodes-base.switch, n8n-nodes-base.extractfromfile, n8n-nodes-tesseractjs.tesseractnode, n8n-nodes-base.if

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Ramdoni.

Original n8n.io source

1.1 Workflow description

Title
Extract invoice data to Excel using Google Gemini, OCR, and Telegram
Workflow name
Extract invoice data to Excel using Google Gemini, OCR, and Telegram

🚀 1. HOW IT WORKS

This workflow automatically extracts structured data from invoices sent via Telegram (PDF or image) and saves it to Excel.

  1. A user sends an invoice (PDF or image) to a Telegram bot
  2. The workflow detects the file type (PDF or image)
  3. For PDF:
  • Extracts text directly from the file
  • Falls back to OCR if needed
  1. For images:
  • Uses OCR to extract text
  1. The extracted text is cleaned and processed
  2. AI (Google Gemini) converts the raw text into structured JSON data
  3. The data is validated and formatted
  4. Valid data is saved to Excel (Microsoft Excel or Google Sheets)
  5. A confirmation message is sent back via Telegram

This eliminates manual data entry and speeds up invoice processing.

⚙️ 2. SETUP INSTRUCTIONS

Prerequisites:

  1. Telegram Bot
  • Create a bot using BotFather
  • Copy the Bot Token
  1. Google Gemini API Key
  • Get API key from Google AI Studio
  1. Excel / Google Sheets
  • Prepare a sheet with columns: invoice_number, date, vendor, total, tax, items

Setup Steps:

  1. Configure Telegram Trigger Node
  • Paste your Bot Token
  1. Configure File Download
  • Ensure binary data is correctly passed
  1. Configure OCR
  • Use Tesseract OCR node or external OCR API
  1. Configure Google Gemini Node
  • Add API key
  • Use provided prompt for structured extraction
  1. Configure Excel / Google Sheets Node
  • Connect your account
  • Map fields correctly
  1. Test Workflow
  • Send a sample invoice via Telegram
  1. Activate Workflow

đź›  Requirements

  • n8n (self-hosted or cloud)
  • Telegram Bot Token
  • Google Gemini API Key
  • Excel 365 or Google Sheets

đź“‚ Output Example

{
 "invoice_number": "INV-001",
 "date": "2025-01-01",
 "vendor": "ABC Company",
 "total_amount": "100000",
 "tax": "10000",
 "items": [
 {
 "name": "Service A",
 "quantity": "1",
 "price": "100000"
 }
 ]
}

🚀 Use Cases

  • Invoice automation
  • Accounts payable automation
  • Financial data entry automation
  • Document digitization

đź’ˇ Notes

  • Works best with clear and high-quality images
  • OCR accuracy depends on image quality
  • AI improves extraction accuracy significantly

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Telegram Trigger

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 2 - Detect File Type

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Notifikasi file invalid

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 4 - Mapping PDF

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - Mapping Image

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 6 - Get Image

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 7 - Get PDF

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 8 - Notifikasi file sedang diproses

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 9 - Clean PDF Text

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Clean OCR Text

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 11 - Route by File Type

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.3

Block 12 - Extract PDF Text

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1.1

Block 13 - Prepare PDF Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 14 - Extract Text from Image (OCR)

Type / Role
n8n-nodes-tesseractjs.tesseractNode - tesseractNode
Config choices
Version 1

Block 15 - Prepare Image Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 16 - Parse AI Response

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Validate Extracted Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Check Data Validity

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 19 - Format Data for Excel

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 20 - Save Data to Excel

Type / Role
n8n-nodes-base.microsoftExcel - microsoftExcel
Config choices
Version 2.2

Block 21 - Send Success Notification

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 22 - Send Invalid Data Notification

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 23 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 34 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Extract invoice data to Excel using Google Gemini, OCR, and Telegram
Complexity advanced
Nodes 34
Categories Invoice Processing, AI Summarization
Author Ramdoni
Published 20 Apr 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15174/15174.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Extract invoice data to Excel using Google Gemini, OCR, and Telegram do?

1. HOW IT WORKS This workflow automatically extracts structured data from invoices sent via Telegram (PDF or image) and saves it to Excel. 1. A user sends an invoice (PDF or image) to a Telegram...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Invoice Processing, AI Summarization use case.