Automatically Classify and Organize PDFs

Jul 16, 2025·3 Minutes Read

What You'll Have When Done: Transform your chaotic file storage into an intelligent system that automatically classifies incoming PDFs and files them into the correct folders based on their content - no more manual sorting required.

Prerequisites

Before you begin, make sure you have:

  • A PDF.co API Key (Get yours here)
  • A Google Drive account with folder structure set up
  • Google Drive OAuth2 credentials configured in n8n
  • An n8n instance (cloud or self-hosted)
  • A designated "incoming" folder in Google Drive for new files
  • Pre-created destination folders matching your classification categories
  • A Document Classifier rule in CSV format and at least one sample document (Samples here and here)

Quick Start Options

Option A: I Want It Working Now

  1. Import this workflow template → Download JSON File
  2. Connect your Google Drive account in n8n
  3. Add your PDF.co API key
  4. Set up your folder structure and classification rules
  5. Configure the watched folder
  6. Test with sample files
  7. Activate and let it run

Option B: I Want to Build It Step-by-Step

Follow the 4-step guide below to create the automation from scratch.

What This Automation Does (Overview)

  1. Monitors a specific Google Drive folder for new PDF files
  2. Classifies each file using PDF.co's intelligent document classifier
  3. Searches for the appropriate destination folder based on classification
  4. Moves the file automatically to the correct organized folder

Step 1: Monitor for New Files

Node: Google Drive Trigger

Settings:

  • Trigger On: Changes Involving a Specific Folder
  • Folder from List: Select your "incoming" or "unsorted" folder
  • Watch For: File Created

Success Looks Like: The trigger activates immediately when a new file is added to your watched folder.

Tip: Create a dedicated "Inbox" folder in Google Drive specifically for this automation to monitor.

Step 2: Classify the Document

Node: HTTP Request (PDF.co Document Classifier)

Settings:

  • Method: POST
  • URL: https://api.pdf.co/v1/pdf/classifier
  • Headers:
    • x-api-key: Your PDF.co API key
    • Content-Type: application/json
  • Body (JSON):
{
    "url": "{{ $json.webContentLink }}",
    "rulescsv": "Amazon AWS, OR, Amazon Web Services Invoice, Amazon CloudFront\nDigital Ocean, OR,DigitalOcean, DOInvoice\nACME,OR, ACME Inc.,1540 Long Street"
}

Customize Your Classification Rules: The rulescsv parameter defines how documents are classified. Format: FolderName, OR, keyword1, keyword2, keyword3

Examples:

  • Invoices, OR, Invoice, Bill, Payment Due
  • Contracts, OR, Agreement, Contract, Terms and Conditions
  • Receipts, OR, Receipt, Purchase, Transaction

Success Looks Like: PDF.co analyzes the document content and returns a classification result with the matched category name. The response includes a classes array with the best match.

Step 3: Find the Destination Folder

Node: Google Drive → Search files and folders

Settings:

  • Resource: File/Folder
  • Operation: Search
  • Query String: ={{ $json.body.classes[0].class }}
  • Filter:
    • Folder ID: Your main organizational folder (parent of all category folders)

Success Looks Like: The search returns the folder that matches the classification result. If "Invoices" was classified, it finds your "Invoices" folder.

Tip: Ensure your folder names exactly match the classification categories you defined in Step 2.

Step 4: Move File to Correct Folder

Congrats! You've built an intelligent file management system that automatically organizes your documents based on their content. Your team can now simply drop files into one folder and watch them get perfectly organized without any manual intervention.

Built something cool? Share it with us @pdfdotco

Related Tutorials

See Related Tutorials