AI Router

Use AI to intelligently route workflow execution based on prompt analysis

Node Type

Conditional

Category

AI & Logic

Icon

AI Brain

Overview

The AI Router node is a powerful conditional node that uses Large Language Models (LLMs) to analyze prompts and intelligently select which downstream node to follow. Instead of traditional rule-based routing, this node leverages AI to understand context and make smart decisions about workflow execution paths.

Key Features

  • AI-Powered Routing: Uses LLMs to analyze prompts and select optimal execution paths
  • Dynamic Node Analysis: Automatically discovers and analyzes available downstream nodes
  • Letter-Based Selection: Maps downstream nodes to letters (A, B, C, D...) for easy AI reference
  • Flexible Execution: Option to allow no execution if no suitable path exists
  • Context-Aware Decisions: Considers node descriptions, types, and categories when routing
  • Cost Tracking: Monitors LLM usage costs for optimization

Prerequisites

AI Service Access

Must have access to LLM services

LLM service properly configured and accessible
Valid API keys and authentication set up
Sufficient API credits for LLM calls

Workflow Structure

Must have multiple downstream paths

At least two downstream nodes connected
Each node should have clear descriptions
Well-designed routing logic and flow

Routing Strategy

Understanding of AI-based decision making

Clear routing criteria and objectives
Understanding of when to use AI vs rule-based routing
Prompt design skills for effective routing

Node Configuration

Required Fields

Prompt

Type:text
Required:Yes
Value Type:string

The prompt or context the AI will analyze to determine routing. Should clearly describe the situation, data, or condition that will inform the routing decision.

Optional Fields

Allow No Execution

Type:boolean
Required:No
Default:false
Value Type:boolean

If true, allows the AI to choose not to execute any downstream node. If false, the AI must select one of the available paths.

Examples & Use Cases

Customer Support Routing

Route customer inquiries to appropriate departments

{
  "prompt": "Customer message: {{customerMessage}}. Route to the most appropriate department.",
  "allowNoExecution": false
}

Downstream nodes: A) Sales Team, B) Technical Support, C) Billing Department. AI analyzes the customer message and routes to the best department.

Content Classification

Classify and route content based on type or sentiment

{
  "prompt": "Email content: {{emailBody}}. Classify as urgent, regular, or spam.",
  "allowNoExecution": true
}

Routes emails to: A) Urgent Processing, B) Regular Inbox, C) Spam Filter, or no action if uncertain.

Dynamic Workflow Selection

Choose different processing pipelines based on data characteristics

{
  "prompt": "Data type: {{dataType}}, size: {{dataSize}}, priority: {{priority}}. Select optimal processing pipeline.",
  "allowNoExecution": false
}

Routes to: A) Fast Processing, B) Detailed Analysis, C) Batch Processing based on data characteristics.

Best Practices

Do's

  • Provide clear, descriptive prompts with relevant context
  • Give downstream nodes meaningful names and descriptions
  • Use the reasoning output for debugging and optimization
  • Monitor costs to optimize AI usage
  • Test with various scenarios to ensure reliable routing
  • Consider using allowNoExecution for uncertain cases

Don'ts

  • Don't use vague or ambiguous prompts
  • Avoid having too many downstream paths (limit to 4-6)
  • Don't forget to provide context in the prompt
  • Avoid using when simple If-Else would suffice
  • Don't ignore the cost implications of frequent AI routing
  • Avoid unclear node names that confuse the AI
💡
Pro Tip: The AI Router is most effective when you have complex, nuanced routing decisions that are hard to express with simple rules. For straightforward comparisons, use the If-Else node to save on AI costs.

Troubleshooting

Common Issues

Inconsistent Routing

Symptoms: AI selects different paths for similar inputs

Solution: Make prompts more specific and provide more context. The AI's probabilistic nature means some variation is normal, but clear prompts reduce inconsistency.

Wrong Path Selected

Symptoms: AI consistently chooses inappropriate paths

Solution: Improve downstream node descriptions to help the AI understand each path's purpose. Add more context to the prompt about what criteria should drive the decision.

High Costs

Symptoms: Routing operations are expensive

Solution: Consider using If-Else nodes for simple conditions and reserve AI Router for complex decisions. Monitor the cost output and optimize prompt length.

Related Resources