# Automated invoice processing with Telegram and OpenAI: n8n workflow

> Started by an incoming Telegram message, and works across Google Sheets and Telegram. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/automated-invoice-processing-with-telegram-and-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Money admin](https://millionrounds.com/workflows?category=Money+admin#library)

# Automated invoice processing with Telegram and OpenAI

Started by an incoming Telegram message, and works across Google Sheets and Telegram. It hands the judgement calls to OpenAI. 27 steps, 2 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomated-invoice-processing-with-telegram-and-openai)

**27 steps** Large: read it before trusting it with anything live

**2** Branches: places the flow splits

**1** Loop or waits

**2** Services it connects to

## The flow

Starts it 2 Model 3 Logic 9 Service 13

The steps in the order they run, from what starts it.

- 1 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 2 **Callback Waiting Answer** Telegram trigger *Starts it*
- 3 **Trigger Receive Message** Telegram trigger *Starts it*
- 4 **Structured Output Parser (Example)** Output Parser Structured *Model*
- 5 **Basic LLM Chain** Chain Llm *Model*
- 6 **Answer?** Switch *Logic*
- 7 **Capture Telegram Data** Set *Logic*
- 8 **Split Out** Split Out *Logic*
- 9 **Connect to SAP** Http Request *Service*
- 10 **No Operation, do nothing** No Op *Logic*
- 11 **File Received** Telegram *Service*
- 12 **Detail** Google Sheets *Service*
- 13 **Get Header** Google Sheets *Service*
- 14 **Download File** Telegram *Service*
- 15 **Header** Google Sheets *Service*
- 16 **Get Row Details** Google Sheets *Service*
- 17 **Merge** Merge *Logic*
- 18 **Upload File LlamaIndex** Http Request *Service*
- 19 **¿Upload to SAP?** Telegram *Service*
- 20 **Generate DocumentLines** Code *Logic*
- 21 **Create JSON** Code *Logic*
- 22 **Validate Status LlamaIndex** Http Request *Service*
- 23 **POST PurchaseInvoices** Http Request *Service*
- 24 **Status?** Switch *Logic*
- 25 **PurchaseInvoices created** Telegram *Service*
- 26 **Get Results LlamaIndex** Http Request *Service*
- 27 **Wait** Wait *Logic*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 27, with 2 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Sheets, Telegram
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Google Sheets and Telegram accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an incoming Telegram message.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 27 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 27 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fautomated-invoice-processing-with-telegram-and-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also money admin, with the same services where possible, closest in size first.

- [**Process and approve invoices with OpenAI and Google Sheets** 27 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/process-and-approve-invoices-with-openai-and-google-sheets)
- [**Automate income and expense tracking in Google Sheets** 27 steps · Google Sheets, Telegram](https://millionrounds.com/workflow/automate-income-and-expense-tracking-in-google-sheets)
- [**Deliver digital products with WhatsApp and Telegram** 27 steps · Google Sheets, Telegram](https://millionrounds.com/workflow/deliver-digital-products-with-whatsapp-and-telegram)
- [**Generate service quotes with OpenAI and Telegram** 26 steps · calls a model · Gmail, Telegram](https://millionrounds.com/workflow/generate-service-quotes-with-openai-and-telegram)
- [**Send donor thank-you receipts and weekly digests** 26 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/send-donor-thank-you-receipts-and-weekly-digests)
- [**Approve invoices with Claude and Google Drive** 28 steps · Google Drive, Google Sheets](https://millionrounds.com/workflow/approve-invoices-with-claude-and-google-drive)
