Skip to main content

Extract purchase order data to Excel via Telegram using OCR and Google Gemini

Workflow preview

Workflow preview
100%
Extract purchase order data to Excel via Telegram using OCR and Google Gemini preview
Open on n8n.io

1. Workflow Overview

Quick Overview This workflow accepts purchase order PDFs or images via Telegram, extracts text using PDF parsing or Tesseract OCR, uses Google Gemini to convert the text into structured JSON, valid...

Best for

  • Document Extraction 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 purchase order data to Excel via Telegram using OCR and Google Gemini
Workflow name
Extract purchase order data to Excel via Telegram using OCR and Google Gemini

Quick Overview

This workflow accepts purchase order PDFs or images via Telegram, extracts text using PDF parsing or Tesseract OCR, uses Google Gemini to convert the text into structured JSON, validates key fields, and appends the results to a Microsoft Excel table in OneDrive, then notifies the sender.

How it works

  1. Triggers when a new Telegram message arrives with a document or photo attachment.
  2. Detects whether the attachment is a PDF or an image and immediately replies in Telegram that processing has started (or sends an invalid-file message if unsupported).
  3. Downloads the file from Telegram and extracts text using built-in PDF text extraction for PDFs or Tesseract OCR for images.
  4. Cleans the extracted text and sends it to Google Gemini with instructions to return purchase order fields and line items as valid JSON.
  5. Parses the Gemini response into JSON and validates that the PO number exists and the total amount is numeric.
  6. If valid, formats the data for a Microsoft Excel table, appends it to the selected workbook/table in OneDrive, and sends a success message in Telegram.
  7. If invalid, sends a Telegram message listing the validation errors.

Setup

  1. Connect your Telegram Bot credential and start a chat with the bot so it can receive PDFs/images and reply to your chat.
  2. Add a Google Gemini (PaLM) API credential and ensure the model ID in the prompt node matches an available Gemini model in your account.
  3. Connect Microsoft Excel OAuth2 credentials, then select the target OneDrive workbook, worksheet, and table where rows should be appended.
  4. (Optional) Adjust the Gemini prompt fields, validation rules, and the Excel column mappings to match your purchase order format and table schema.

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 - Extract Structured Data (AI)

Type / Role
@n8n/n8n-nodes-langchain.googleGemini - googleGemini
Config choices
Version 1

Block 24 - Sticky Note

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

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

3. Summary Table

Workflow Extract purchase order data to Excel via Telegram using OCR and Google Gemini
Complexity advanced
Nodes 31
Categories Document Extraction, AI Summarization
Author Ramdoni
Published 08 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16172/16172.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 purchase order data to Excel via Telegram using OCR and Google Gemini do?

Quick Overview This workflow accepts purchase order PDFs or images via Telegram, extracts text using PDF parsing or Tesseract OCR, uses Google Gemini to convert the text into structured JSON, valid...

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 Document Extraction, AI Summarization use case.