Route chat requests through tiered AI agents using OpenRouter and LangChain
Ready for 3.0What this workflow does
This AI workflow has 23 nodes and runs when a chat message arrives. Along the way it connects OpenRouter Chat Model and Wikipedia.
How it runs
Trigger: When a chat message arrives.
- Validate and Normalize Payload (Edit Fields (Set)): sets 3 fields: userRequest, sessionId, receivedAt
- Score Cost, Risk and Latency (Code): runs custom JavaScript code
- Route Request by Tier (Switch): routes items into 4 branches
- Return Guardrail Message (Edit Fields (Set)): sets 1 field: output
- Small Reasoning Agent (AI Agent): runs an AI agent, with model: Small Model (Fast Tier); 1 tool (Inference Time Thinking); memory: Shared Session Memory
- Domain Specialist Agent (AI Agent): runs an AI agent, with model: Domain Model (Specialist Tier); memory: Shared Session Memory
- Agentic Orchestrator (AI Agent): runs an AI agent, with model: Orchestrator Model (Reasoning Tier); 6 tools (Calculator, Critic Agent, Wikipedia, Domain Specialist…); memory: Shared Session Memory
- Compose Reply and Telemetry (Edit Fields (Set)): sets 7 fields: output, route, domain…
Services it uses
Other OpenRouter + Wikipedia templates (4)
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (11)
- Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - Switch
n8n-nodes-base.switch - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenRouter Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenRouter - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - Think Tool
@n8n/n8n-nodes-langchain.toolThink - AI Agent Tool
@n8n/n8n-nodes-langchain.agentTool - Calculator
@n8n/n8n-nodes-langchain.toolCalculator - Wikipedia
@n8n/n8n-nodes-langchain.toolWikipedia
From the author
Quick Overview This workflow provides a tiered chat assistant that validates each request, scores it for domain, complexity, and risk, then routes it to a fast OpenRouter model, a domain-specialist OpenRouter model, or a multi-agent OpenRouter orchestrator…