Automation library · Documents and files

Classify and file email PDF documents with Gmail and Drive

Started by an arriving email, and works across Gmail, Google Drive, Google Sheets and Slack. It hands the judgement calls to Claude. 22 steps, 3 branches: large, and worth reading before you trust it with anything live.

LargeCalls a model: Claude

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

The flow

Starts it 1Model 2Logic 13Service 6

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

  1. 1When Email ReceivedGmail triggerStarts it
  2. 2Anthropic Chat ModelLm Chat AnthropicModel
  3. 3Set Folder and Index IDsSetLogic
  4. 4Document Type ClassifierInformation ExtractorModel
  5. 5Extract Each AttachmentCodeLogic
  6. 6Merge for FilingMergeLogic
  7. 7Check PDF FormatIfLogic
  8. 8Route by Document TypeSwitchLogic
  9. 9Fetch PDF MetadataPdf RestService
  10. 10Merge PDF DataMergeLogic
  11. 11Prepare Invoice for FilingSetLogic
  12. 12Prepare Contract for FilingSetLogic
  13. 13Prepare Correspondence for FilingSetLogic
  14. 14Prepare Other Documents for FilingSetLogic
  15. 15Check OCR RequirementIfLogic
  16. 16Upload Document to DriveGoogle DriveService
  17. 17Apply OCR to PDFPdf RestService
  18. 18Set OCR Status SkippedSetLogic
  19. 19Log to Index SheetGoogle SheetsService
  20. 20Set OCR Status AppliedSetLogic
  21. 21Convert PDF to MarkdownPdf RestService
  22. 22Post Slack NotificationSlackService

How it's built

Starts on
An arriving email
Steps
22, with 3 branches
Size
Large: read it before trusting it with anything live
Connects to
Gmail, Google Drive, Google Sheets, Slack
Model
Claude

Questions

What does it need to run?

An n8n account, plus your own Gmail, Google Drive, Google Sheets and Slack accounts, and a key for Claude. 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 Claude. 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.