Automation library · Money admin

Extract and organize Colombian invoices with Gmail and OpenAI

Started by an arriving email, and works across Gmail, Google Drive and Google Sheets. It hands the judgement calls to OpenAI. 22 steps, 1 branch, 1 loop or waits: large, and worth reading before you trust it with anything live.

LargeCalls a model: OpenAI

22 stepsLarge: read it before trusting it with anything live
1Branch: places the flow splits
1Loop or waits
3Services it connects to

The flow

Starts it 1Model 4Logic 11Service 6

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

  1. 1OpenAI Chat ModelLm Chat Open AiModel
  2. 2CalculatorTool CalculatorModel
  3. 3Structured Output ParserOutput Parser StructuredModel
  4. 4On Email receiptGmail triggerStarts it
  5. 5Extract Data from PDF and XMLAgentModel
  6. 6Get Filename and mimeTypeCodeLogic
  7. 7Merge both flowsMergeLogic
  8. 8Filter ZIP files onlyFilterLogic
  9. 9Update PDF with actual nameGoogle DriveService
  10. 10Unzip InvoiceCompressionService
  11. 11Get Current DateCodeLogic
  12. 12Loop Over ItemsSplit In BatchesLogic
  13. 13Create or update rowGoogle SheetsService
  14. 14Just for styleNo OpLogic
  15. 15Get filename and mimeType on extracted docsCodeLogic
  16. 16Split XML and PDFSwitchLogic
  17. 17Create initial PDFGoogle DriveService
  18. 18Extract PDF DataExtract From FileService
  19. 19Extract XML DataExtract From FileService
  20. 20Append both DocsMergeLogic
  21. 21Convert to JSONXmlLogic
  22. 22Aggregate all Data into 1 listAggregateLogic

How it's built

Starts on
An arriving email
Steps
22, with 1 branch, 1 loop or waits
Size
Large: read it before trusting it with anything live
Connects to
Gmail, Google Drive, Google Sheets
Model
OpenAI

Questions

What does it need to run?

An n8n account, plus your own Gmail, Google Drive and Google Sheets 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 22 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 22 steps before you point it at anything that matters.