Automation library · Money admin

Collect invoices from Gmail and save them

Started by an arriving email, and works across Gmail, Google Drive and Google Sheets. It hands the judgement calls to OpenAI. 20 steps, 3 branches: a working afternoon to understand properly.

MediumCalls a model: OpenAI

20 stepsMedium: a working afternoon
3Branches: places the flow splits
0Loops or waits
3Services it connects to

The flow

Starts it 1Model 3Logic 8Service 8

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

  1. 1Gmail TriggerGmail triggerStarts it
  2. 2OpenAI Chat ModelLm Chat Open AiModel
  3. 3Invoice PickerAgentModel
  4. 4Invoice AI AgentAgentModel
  5. 5Extract basic informationCodeLogic
  6. 6Code in JavaScriptCodeLogic
  7. 7Invoice FilterFilterLogic
  8. 8Ensure strict structureCodeLogic
  9. 9Label invoices in the mailboxGmailService
  10. 10Final Spreadsheet with Invoice dataGoogle SheetsService
  11. 11Assign to a periodDate TimeLogic
  12. 12Ensure the sheet exist in the spreadsheetGoogle SheetsService
  13. 13Is the invoice attached?IfLogic
  14. 14Search for the destination folderGoogle DriveService
  15. 15Need to create the folder?IfLogic
  16. 16Create folderGoogle DriveService
  17. 17Search for the invoice fileGoogle DriveService
  18. 18Upload fileGoogle DriveService
  19. 19Need to upload the invoice?IfLogic
  20. 20Extract Invoice dataExtract From FileService

How it's built

Starts on
An arriving email
Steps
20, with 3 branches
Size
Medium: a working afternoon
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?

Plan an afternoon. 20 steps is enough that you should read each one before running it.

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