🧾 Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration

27,220 views · 🧾 Invoice Processing

💡 Pro Tip — HTTP Request scraping tends to break when sites update their markup. If you’re scraping a major platform, check if ScraperNode covers it — it has maintained scrapers for LinkedIn, Instagram, TikTok, YouTube, and 20+ other platforms that return structured data.

View All Scrapers

Description

++HOW IT WORKS:++ This workflow automates the processing of invoices sent via Telegram. It extracts the data using LlamaIndex OCR, logs it in Google Sheets, and optionally pushes the structured data to SAP Business One

🔹 1. Receive Invoice via Telegram:

🔹 2. OCR with LlamaIndex:

🔹 3. Data Extraction via LLM (editable):

🔹 4. Save to Google Sheets: The structured JSON is split into:

  1. Header (main invoice metadata)
  2. Detail (individual line items)

Each part is stored in a dedicated tab within a connected Google Sheets file

🔹 5. Ask for SAP Confirmation: The bot replies to the user via Telegram:

“Do you want to send the data to SAP?”

If the user clicks “Yes”, the next automation path is triggered.

🔹 6. Push Data to SAP B1: A connection is made to SAP Business One’s Service Layer API

Header and detail data are fetched from Google Sheets

The invoice structure is rebuilt as required by SAP (DocumentLines, CardCode, etc.)

A POST request creates the Purchase Invoice in SAP

A confirmation message with the created DocEntry is sent back to the user on Telegram

++SET UP STEPS:++ Follow these steps to properly configure the workflow before execution:

1️⃣ Create Required Credentials: Go to Credentials > + New Credential and create the following:

2️⃣ Set Up Environment Variables (Optional but Recommended): LLAMAINDEX_API_KEY SAP_USER SAP_PASSWORD SAP_COMPANY_DB SAP_URL

3️⃣ Prepare Google Sheets: Ensure your Google Spreadsheet has the following: ➤ Sheet 1: Header ➤ Sheet 2: Details Contains columns for invoice lines

🔗 Nodes Used

Google Sheets, HTTP Request, Telegram, Telegram Trigger, Basic LLM Chain, OpenAI Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup