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 Triggers when a new Telegram message arrives with a document or photo attachment. 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). Downloads the file from Telegram and extracts text using built-in PDF text extraction for PDFs or Tesseract OCR for images. Cleans the extracted text and sends it to Google Gemini with instructions to return purchase order fields and line items as valid JSON. Parses the Gemini response into JSON and validates that the PO number exists and the total amount is numeric. 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. If invalid, sends a Telegram message listing the validation errors.

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

0
Downloads
2
Views
8.44
Quality Score
beginner
Complexity
Author:Ramdoni(View Original →)
Created:6/25/2026
Updated:6/25/2026

🔒 Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments