Skip to main content

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

Workflow preview

Workflow preview
100%
Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

++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 dat...

Best for

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

Tools used

n8n-nodes-base.wait, @n8n/n8n-nodes-langchain.chainllm, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.noop, n8n-nodes-base.splitout, n8n-nodes-base.merge, n8n-nodes-base.stickynote, n8n-nodes-base.telegramtrigger

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration
Workflow name
Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration

++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:

  • A user sends a PDF of an invoice through Telegram
  • A Telegram Trigger node listens for incoming messages and captures the file and metadata
  • The document is downloaded and prepared for OCR

🔹 2. OCR with LlamaIndex:

  • The file is uploaded to the LlamaIndex OCR API.
  • The workflow polls the API until the processing status returns SUCCESS
  • Once ready, the parsed content is fetched in Markdown format

🔹 3. Data Extraction via LLM (editable):

  • The Markdown content is sent to a language model (LLM) using LangChain
  • A Structured Output Parser transforms the result into a clean, structured editable JSON

🔹 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:

  • Telegram API (set your bot token get it from BotFather)
  • Google Sheets
  • OpenAI

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

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 - Wait

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

Block 2 - Basic LLM Chain

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 3 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 4 - No Operation, do nothing

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

Block 5 - Split Out

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

Block 6 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 7 - Sticky Note

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

Block 8 - Callback Waiting Answer

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

Block 9 - Answer?

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

Block 10 - Connect to SAP

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 11 - Get Header

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 12 - Get Row Details

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 13 - Generate DocumentLines

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

Block 14 - Create JSON

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

Block 15 - POST PurchaseInvoices

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 16 - PurchaseInvoices created

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

Block 17 - Trigger Receive Message

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

Block 18 - Capture Telegram Data

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

Block 19 - File Received

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

Block 20 - Download File

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

Block 21 - Upload File LlamaIndex

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 22 - Validate Status LlamaIndex

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 23 - Status?

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

Block 24 - Get Results LlamaIndex

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

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

3. Summary Table

Workflow Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration
Complexity advanced
Nodes 29
Categories Invoice Processing, AI Summarization
Author Raquel Giugliano
Published 10 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4849/4849.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 Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration do?

++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 dat...

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.