Router
Route workflow execution based on specific conditions or logic
The Router block uses AI to intelligently decide which path your workflow should take next. Unlike Condition blocks that use simple rules, Router blocks can understand context and make smart routing decisions based on content analysis.
Overview
The Router block enables you to:
Intelligent content routing: Use AI to understand intent and context
Dynamic path selection: Route workflows based on unstructured content analysis
Context-aware decisions: Make smart routing choices beyond simple rules
Multi-path management: Handle complex workflows with multiple potential destinations
Router vs Condition Blocks
How It Works
The Router block:
Analyze content: Uses an LLM to understand input content and context
Evaluate targets: Compares content against available destination blocks
Select destination: Identifies the most appropriate path based on intent
Route execution: Directs workflow to the selected block
Configuration Options
Content/Prompt
The content or prompt that the Router will analyze to make routing decisions. This can be:
- A direct user query or input
- Output from a previous block
- A system-generated message
Target Blocks
The possible destination blocks that the Router can select from. The Router will automatically detect connected blocks, but you can also:
- Customize the descriptions of target blocks to improve routing accuracy
- Specify routing criteria for each target block
- Exclude certain blocks from being considered as routing targets
Model Selection
Choose an AI model to power the routing decision:
OpenAI: GPT-4o, o1, o3, o4-mini, gpt-4.1
Anthropic: Claude 3.7 Sonnet
Google: Gemini 2.5 Pro, Gemini 2.0 Flash
Other Providers: Groq, Cerebras, xAI, DeepSeek
Local Models: Any model running on Ollama
Recommendation: Use models with strong reasoning capabilities like GPT-4o or Claude 3.7 Sonnet for more accurate routing decisions.
API Key
Your API key for the selected LLM provider. This is securely stored and used for authentication.
Accessing Results
After a router makes a decision, you can access its outputs:
<router.content>
: Summary of the routing decision made<router.selected_path>
: Details of the chosen destination block<router.tokens>
: Token usage statistics from the LLM<router.model>
: The model used for decision-making
Advanced Features
Custom Routing Criteria
Define specific criteria for each target block:
// Example routing descriptions
Target Block 1: "Technical support issues, API problems, integration questions"
Target Block 2: "Billing inquiries, subscription changes, payment issues"
Target Block 3: "General questions, feedback, feature requests"
Multi-Model Routing
Use different models for different routing scenarios:
// Fast routing for simple cases
Model: GPT-4o-mini
Criteria: Simple, common routing patterns
// Complex routing for nuanced decisions
Model: Claude 3.7 Sonnet
Criteria: Complex content analysis required
Fallback Handling
Implement robust fallback mechanisms:
// Router configuration
Primary Targets: ["Support", "Sales", "Technical"]
Fallback Target: "General" // Default when no specific match
Confidence Threshold: 0.7 // Minimum confidence for routing
Inputs and Outputs
Content/Prompt: Text to analyze for routing decisions
Target Blocks: Connected blocks as potential destinations
Model: AI model for routing analysis
API Key: Authentication for selected LLM provider
router.content: Summary of routing decision
router.selected_path: Details of chosen destination
router.tokens: Token usage statistics
router.model: Model used for decision-making
Routing Decision: Primary path selection result
Decision Context: Analysis summary and reasoning
Access: Available in blocks after the router
Example Use Cases
Customer Support Triage
Scenario: Route support tickets to specialized departments
- User submits support request via form
- Router analyzes ticket content and context
- Technical issues → Engineering support agent
- Billing questions → Finance support agent
Content Classification
Scenario: Classify and route user-generated content
- User submits content or feedback
- Router analyzes content type and sentiment
- Feature requests → Product team workflow
- Bug reports → Technical support workflow
Lead Qualification
Scenario: Route leads based on qualification criteria
- Lead information captured from form
- Router analyzes company size, industry, and needs
- Enterprise leads → Sales team with custom pricing
- SMB leads → Self-service onboarding flow
Best Practices
- Provide clear target descriptions: Help the Router understand when to select each destination with specific, detailed descriptions
- Use specific routing criteria: Define clear conditions and examples for each path to improve accuracy
- Implement fallback paths: Connect a default destination for when no specific path is appropriate
- Test with diverse inputs: Ensure the Router handles various input types, edge cases, and unexpected content
- Monitor routing performance: Review routing decisions regularly and refine criteria based on actual usage patterns
- Choose appropriate models: Use models with strong reasoning capabilities for complex routing decisions