Automation library · Money admin

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.

LargeCalls a model: OpenAI

27 stepsLarge: read it before trusting it with anything live
2Branches: places the flow splits
1Loop or waits
2Services it connects to

The flow

Starts it 2Model 3Logic 9Service 13

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

  1. 1OpenAI Chat ModelLm Chat Open AiModel
  2. 2Callback Waiting AnswerTelegram triggerStarts it
  3. 3Trigger Receive MessageTelegram triggerStarts it
  4. 4Structured Output Parser (Example)Output Parser StructuredModel
  5. 5Basic LLM ChainChain LlmModel
  6. 6Answer?SwitchLogic
  7. 7Capture Telegram DataSetLogic
  8. 8Split OutSplit OutLogic
  9. 9Connect to SAPHttp RequestService
  10. 10No Operation, do nothingNo OpLogic
  11. 11File ReceivedTelegramService
  12. 12DetailGoogle SheetsService
  13. 13Get HeaderGoogle SheetsService
  14. 14Download FileTelegramService
  15. 15HeaderGoogle SheetsService
  16. 16Get Row DetailsGoogle SheetsService
  17. 17MergeMergeLogic
  18. 18Upload File LlamaIndexHttp RequestService
  19. 19¿Upload to SAP?TelegramService
  20. 20Generate DocumentLinesCodeLogic
  21. 21Create JSONCodeLogic
  22. 22Validate Status LlamaIndexHttp RequestService
  23. 23POST PurchaseInvoicesHttp RequestService
  24. 24Status?SwitchLogic
  25. 25PurchaseInvoices createdTelegramService
  26. 26Get Results LlamaIndexHttp RequestService
  27. 27WaitWaitLogic

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.