Classify and route uploaded documents to Google Drive with an AI agent
Go to WorkflowDescription
What This Workflow Does
Upload a document (PDF, PNG, JPEG) via a web form and let an AI agent classify it and route it to the correct Google Drive folder on its own. No rule-based routing, no Switch nodes – the agent decides the category and calls the matching move tool. Documents it can't confidently classify are moved to a Needs Review folder and flagged via Slack.
How It Works
User uploads a file through the hosted web form
The file is uploaded to a temporary Incoming folder in Google Drive
The file ID and name are passed to the AI Agent
The agent classifies the document and calls the matching Move tool (e.g. move_to_medical)
If it can't confidently classify, it calls Move to Needs Review + sends a Slack alert
Supported categories:
medical_invoice · restaurant_invoice · hotel_invoice · trades_invoice · telecom_invoice
Setup Guide
1. Create Your Google Drive Folders
Create one folder per category in Google Drive:
Incoming** (temporary landing folder)
Medical* · *Restaurant* · *Hotel* · *Trades* · *Telecom**
Needs Review**
2. Connect Google Drive
In n8n, go to Settings → Credentials and create a Google Drive OAuth2 credential
This requires a Client ID and Client Secret from Google Cloud Console (APIs & Services → Credentials → OAuth 2.0 Client ID)
Make sure the Google Drive API is enabled in your Google Cloud project
Open the Upload to Incoming Folder node and select your Incoming folder
Open each of the 6 Move tool nodes and select the correct target folder
3. Connect Your Chat Model
Add a credential for your chosen model (Gemini, OpenAI, Anthropic) in Settings → Credentials
Open the Chat Model node and assign the credential
Any tool-calling capable model will work – Gemini 1.5 Pro or GPT-4o recommended
4. Connect Slack
Create a Slack API credential in n8n (needs a Bot Token with chat:write scope)
Create a channel for review notifications (e.g. #document-review)
Invite the bot to that channel
Open the Slack: Notify Review Channel node and select the correct channel
5. Activate & Test
Click Active in the top-right corner of n8n
Open the form URL and upload a test document
Check the execution log to confirm the classification and the move action
Verify the file lands in the correct Google Drive folder
Test with an unrecognizable document to confirm the Slack alert fires
Notes
The agent's classification quality depends on the filename and the chat model's reasoning. Descriptive filenames improve accuracy significantly.
This workflow is an agentic demo – it replaces deterministic routing with LLM decision-making. For production-grade document classification with structured extraction, per-field prompting, and explicit confidence scoring, check out the easybits Extractor community node.