Automation library · Money admin

Invoice processing: Email to PostgreSQL database with OpenAI

Started by an arriving email, and works across Discord, Email and Postgres. It hands the judgement calls to OpenAI. 23 steps, 5 branches: large, and worth reading before you trust it with anything live.

LargeCalls a model: OpenAI

23 stepsLarge: read it before trusting it with anything live
5Branches: places the flow splits
0Loops or waits
3Services it connects to

The flow

Model 3Logic 13Service 7

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

  1. 1Email Trigger (IMAP)Email Read ImapService
  2. 2OpenAI Chat ModelLm Chat Open AiModel
  3. 3Structured Output ParserOutput Parser StructuredModel
  4. 4IfIfLogic
  5. 5Basic LLM ChainChain LlmModel
  6. 6CodeCodeLogic
  7. 7MergeMergeLogic
  8. 8If1IfLogic
  9. 9If2IfLogic
  10. 10Extract from File1Extract From FileService
  11. 11DiscordDiscordService
  12. 12Prepare Company DataSetLogic
  13. 13Check CompanyPostgresService
  14. 14IF Company Does Not ExistIfLogic
  15. 15Add CompanyPostgresService
  16. 16Set Existing Company IDSetLogic
  17. 17Set New Company IDSetLogic
  18. 18Merge Company IDMergeLogic
  19. 19Check InvoicePostgresService
  20. 20IF Invoice Does Not ExistIfLogic
  21. 21Add InvoicePostgresService
  22. 22Invoice ExistsSetLogic
  23. 23Merge EndMergeLogic

How it's built

Starts on
An arriving email
Steps
23, with 5 branches
Size
Large: read it before trusting it with anything live
Connects to
Discord, Email, Postgres
Model
OpenAI

Questions

What does it need to run?

An n8n account, plus your own Discord, Email and Postgres accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an arriving email.

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 23 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 23 steps before you point it at anything that matters.