This workflow demonstrates an AI task routing system using multiple agents in n8n. It analyzes incoming user requests, determines their complexity, and routes them to the most appropriate AI agent for processing.
A Supervisor Agent evaluates each request and classifies it as either simple or complex, returning a confidence score and reasoning. Based on this classification, an orchestrator agent delegates the task to the correct specialized agent.
The workflow also includes a confidence validation mechanism. If the classification confidence falls below a defined threshold, an email alert is sent to an administrator for manual review.
This architecture helps build scalable AI systems where tasks are intelligently routed to agents optimized for different levels of complexity.
Webhook Trigger
The workflow starts when a request is received through a webhook endpoint.
Workflow Configuration
The request and a configurable confidence threshold are stored using a Set node.
Supervisor Agent Classification
The Supervisor Agent analyzes the user request and determines whether the task is simple or complex, returning a confidence score and reasoning.
Structured Output Parsing
The classification result is parsed using a structured output parser to ensure reliable JSON formatting.
Confidence Validation
An IF node checks whether the confidence score meets the configured threshold.
Agent Orchestration
If the confidence is sufficient, an orchestrator agent delegates the task to either:
Fallback Handling
If the confidence score is too low, the workflow sends an email alert requesting manual review.
Webhook Response
The final AI response is returned to the original requester through the Respond to Webhook node.
Add OpenAI credentials to all OpenAI model nodes:
Configure the Workflow Configuration node:
userRequest placeholder if testing manually.confidenceThreshold if required.Configure the Email Send node:
Activate the workflow and send requests to the Webhook endpoint to start task processing.