Built two separate n8n agents: One monitors email. Another handles accounting. Connected them. Now they coordinate automatically - email agent briefs accounting agent with invoice data.
THE PROBLEM WITH SINGLE AGENTS:
One agent trying to do everything: monitor email, parse documents, check duplicates, post to QuickBooks. Gets confused. Makes errors. Too many tools overload the context.
THE MULTI-AGENT SOLUTION:
Split responsibilities. Specialized agents. Each does one thing excellently.
AGENT 1: EMAIL MONITOR AGENT
Role: Watch Gmail, identify invoices, extract data.
Tools: Gmail trigger, document parsing tool, confidence scoring.
Output: Structured invoice summary with confidence score.
Workflow: Receives email → Checks for invoice keywords → Parses PDF attachment → Extracts vendor, amount, date, invoice number → Scores confidence → Passes to router.
AGENT 2: ACCOUNTING AGENT
Role: Process financial data, post transactions, check duplicates.
Tools: QuickBooks API, Google Sheets, duplicate detection database.
Output: Posted transaction confirmation, notification.
Workflow: Receives invoice summary → Checks for duplicates → Validates data → Posts to QuickBooks → Updates tracking sheet → Sends confirmation.
THE COORDINATION LAYER:
Router node between agents. Checks confidence score from Email Agent.
High confidence (above 0.90): Sends directly to Accounting Agent.
Medium confidence (0.75-0.90): Sends with review flag.
Low confidence (below 0.75): Human approval required first.
DATA PASSING:
Email Agent outputs:
vendor_name, invoice_amount, due_date, invoice_number, confidence_score, pdf_url
Accounting Agent receives:
Same structured data, processes automatically or flags for review based on confidence.
THE COMPLETE FLOW:
Gmail Trigger → Email Agent (with document processing tool) → Confidence Router → Accounting Agent → Post to QuickBooks → Notify
THE NUMBERS:
- 40 invoices monthly processed
- 36 posted automatically (90%)
- 4 flagged for review (10%)
- Accuracy: 95% on auto-posted invoices
- Time saved: 8 hours monthly vs manual processing
WHY THIS WORKS:
Separation of concerns. Email Agent focuses on document understanding. Accounting Agent focuses on financial logic. Neither overloaded.
Agent coordination pattern: Output from one agent becomes input to next agent. Clean handoff. Clear responsibilities.
CONFIGURATION:
Email Agent: AI Agent node with document processing tool. Tool executes subworkflow for parsing.
Accounting Agent: Separate AI Agent node with QuickBooks and Sheets tools. Receives structured data via webhook.
Router: IF node checking confidence_score field. Three branches for different confidence levels.
TEMPLATE PATTERN:
This multi-agent pattern works for any complex workflow. Replace email monitoring with form processing. Replace accounting with CRM posting. Same coordination pattern.
Multi-agent workflow templates with document processing here What multi-agent patterns are you building?