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 with critic and scenario simulation tools.
How it works
- Receives a chat request via an n8n Chat Trigger webhook.
- Normalizes the incoming payload, extracting the user request text and session ID and adding a timestamp.
- Scores the request for domain hints, complexity, and guardrail risks (empty, oversized, or prompt-injection markers) and assigns a routing tier.
- If the request is blocked, returns a guardrail message without calling any language model.
- If the request is simple, uses OpenRouter with shared session memory to generate a concise response.
- If the request matches a domain (code, legal, finance, bio, or science), uses an OpenRouter domain-specialist agent with shared session memory to produce a structured answer.
- If the request is complex, uses an OpenRouter orchestrator that plans the work and can consult a specialist sub-agent, a critic, a scenario simulator, Wikipedia, and a calculator before returning the final response.
- Returns the final reply along with telemetry fields (route, domain, complexity score, risk level, and timestamps) as the chat response.
Setup
- Add an OpenRouter API credential and select it for all OpenRouter Chat Model nodes used by the fast, specialist, orchestrator, and tool agents.
- Confirm the configured OpenRouter models (including openai/gpt-4.1 for the orchestrator tier) are available to your OpenRouter account.
- Enable the workflow and use the Chat Trigger test/production URL to send messages into the workflow from your chat client or integration.