Route AI tasks between OpenAI agents with confidence-based email fallback
Overview
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.
How It Works
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:
Simple Task Agent for straightforward questions
Complex Task Agent for tasks requiring deeper reasoning
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.
Setup Instructions
Add OpenAI credentials to all OpenAI model nodes: Supervisor Model Executor Model Simple Agent Model Complex Agent Model
Configure the Workflow Configuration node: Set the userRequest placeholder if testing manually. Adjust the confidenceThreshold if required.
Configure the Email Send node: Enter sender and administrator email addresses. Connect SMTP or your preferred email credentials.
Activate the workflow and send requests to the Webhook endpoint to start task processing.
Use Cases
AI support systems that route queries based on complexity
Customer service automation with intelligent escalation
Multi-agent AI architectures for research or analysis tasks
AI workflow orchestration for automation platforms
Intelligent request classification and routing systems
Requirements
OpenAI API credentials**
Email (SMTP) credentials** for alert notifications
A system capable of sending requests to the workflow webhook
Related Templates
Automatic News Summarization & Email Digest with GPT-4, NewsAPI and Gmail
📰 AI News Digest Agent: Auto News Summarizer & Email Newsletter Create an intelligent news curation system that automat...
Generate Food Recipes from Gmail & Form Requests with Ollama & Llama 3.2
This n8n template demonstrates how to create an intelligent food recipe assistant that accepts requests via Gmail and we...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments