Skip to main content

Route AI tasks between OpenAI agents with confidence-based email fallback

Workflow preview

Workflow preview
100%
Route AI tasks between OpenAI agents with confidence-based email fallback preview
Open on n8n.io

1. Workflow Overview

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...

Best for

  • Engineering automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.set, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.outputparserstructured, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.if, n8n-nodes-base.emailsend, n8n-nodes-base.stickynote, n8n-nodes-base.webhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by ResilNext.

Original n8n.io source

1.1 Workflow description

Title
Route AI tasks between OpenAI agents with confidence-based email fallback
Workflow name
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

  1. Webhook Trigger The workflow starts when a request is received through a webhook endpoint.

  2. Workflow Configuration The request and a configurable confidence threshold are stored using a Set node.

  3. 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.

  4. Structured Output Parsing The classification result is parsed using a structured output parser to ensure reliable JSON formatting.

  5. Confidence Validation An IF node checks whether the confidence score meets the configured threshold.

  6. 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
  1. Fallback Handling If the confidence score is too low, the workflow sends an email alert requesting manual review.

  2. Webhook Response The final AI response is returned to the original requester through the Respond to Webhook node.


Setup Instructions

  1. Add OpenAI credentials to all OpenAI model nodes:
  • Supervisor Model
  • Executor Model
  • Simple Agent Model
  • Complex Agent Model
  1. Configure the Workflow Configuration node:
  • Set the userRequest placeholder if testing manually.
  • Adjust the confidenceThreshold if required.
  1. Configure the Email Send node:
  • Enter sender and administrator email addresses.
  • Connect SMTP or your preferred email credentials.
  1. 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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Workflow Configuration

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 2 - Supervisor Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 3 - Routing Decision Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 4 - OpenAI Model - Supervisor

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 5 - Check Confidence Score

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 6 - OpenAI Model - Simple Agent

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 7 - Execute Selected Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 8 - OpenAI Model - Executor

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 9 - Send Fallback Alert

Type / Role
n8n-nodes-base.emailSend - emailSend
Config choices
Version 2.1

Block 10 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 16 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.5

Block 18 - OpenAI Model - Complex Agent GPT 5.3

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 19 - Complex Task Agent Tool (5.4)

Type / Role
@n8n/n8n-nodes-langchain.agentTool - agentTool
Config choices
Version 2.2

Block 20 - Simple Task Agent Tool(5 MINI)

Type / Role
@n8n/n8n-nodes-langchain.agentTool - agentTool
Config choices
Version 2.2

Block 21 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Route AI tasks between OpenAI agents with confidence-based email fallback
Complexity advanced
Nodes 21
Categories Engineering, AI Chatbot
Author ResilNext
Published 09 Mar 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/13965/13965.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Route AI tasks between OpenAI agents with confidence-based email fallback do?

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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI Chatbot use case.