Skip to main content

Dynamic Routing Template

Route requests to different processing paths based on content, priority, user type, or any custom logic. Build intelligent workflows that adapt to each scenario.

Time to build: 15 minutes Difficulty: Intermediate Perfect for: Customer support triage, lead qualification, content categorization, smart routing


What It Does

Input → Classify → Route to appropriate handler → Process → Respond

Different inputs take different paths through your workflow.


Step-by-Step

1. Create Workflow

  • New workflow → Name it "Smart Customer Support Router"
  • Webhook trigger for customer inquiries

2. Add Classification Agent

  • Drag Agent Block
  • Connect Webhook to Agent
Model: GPT-4o-mini (fast classification)

System Prompt:
"Classify this customer inquiry into ONE category:
- TECHNICAL: Bug reports, technical issues
- BILLING: Payment, invoices, subscriptions
- SALES: Product questions, pricing
- URGENT: Account locked, data loss, security
- GENERAL: Other questions

Return ONLY the category name."

User Prompt:
"Customer: <webhook.body.customer_name>
Message: <webhook.body.message>"

3. Add Priority Check Condition

  • Drag Condition Block
  • Connect Agent to Condition
Condition: <agent.content> == "URGENT"

If True: Fast-track to priority handler
If False: Continue to category routing

4. Handle Urgent (True Path)

  • Drag Parallel Block on True path

Parallel Actions:

  1. Slack notification to #urgent-support
  2. PagerDuty alert to on-call engineer
  3. Email to customer with immediate response

5. Add Category Router (False Path)

  • Drag multiple Condition Blocks in sequence

First Condition:

Condition: <agent.content> == "TECHNICAL"
True: Route to technical handler
False: Check next category

Second Condition:

Condition: <agent.content> == "BILLING"
True: Route to billing handler
False: Check next category

Third Condition:

Condition: <agent.content> == "SALES"
True: Route to sales handler
False: Route to general handler

6. Create Technical Handler

  • Drag Agent Block on Technical path
Model: Claude 3.7 Sonnet

System Prompt:
"You are a technical support specialist. Help debug the issue, provide solutions, and link to documentation."

User Prompt: <webhook.body.message>

Tools: [Knowledge Base (docs), GitHub Issues]

7. Create Billing Handler

  • Drag Agent Block on Billing path
Model: GPT-4o

System Prompt:
"You are a billing specialist. Help with payment issues, subscriptions, and invoices. Check customer account status first."

User Prompt:
"Customer: <webhook.body.customer_id>
Issue: <webhook.body.message>"

Tools: [Database Query (billing), Stripe API]

8. Create Sales Handler

  • Drag Agent Block on Sales path
Model: Claude 3.7 Sonnet

System Prompt:
"You are a sales assistant. Answer product questions, explain pricing, and encourage trial signup."

User Prompt: <webhook.body.message>

Tools: [Knowledge Base (product docs), Pricing API]

9. Create General Handler

  • Drag Agent Block on General path
Model: GPT-4o-mini

System Prompt:
"You are a helpful assistant. Answer general questions politely and concisely."

User Prompt: <webhook.body.message>

10. Merge Responses

  • Drag Response Block
  • Connect all handler outputs to single Response
{
"category": "<agent_classifier.content>",
"response": "<agent_handler.content>",
"customer_id": "<webhook.body.customer_id>",
"timestamp": "<webhook.timestamp>"
}

11. Log to Database

  • Drag Database Query
INSERT INTO support_tickets (
customer_id,
category,
message,
response,
created_at
) VALUES (
'<webhook.body.customer_id>',
'<agent_classifier.content>',
'<webhook.body.message>',
'<agent_handler.content>',
NOW()
)

Routing Strategies

Simple Classification

  • Category-based routing (like example above)
  • One classifier, multiple handlers

Multi-Condition Routing

  • Check priority first
  • Then category
  • Then complexity

Confidence-Based Routing

  • AI returns confidence score
  • Route to human if confidence < 80%

User-Based Routing

  • Check customer tier (free, pro, enterprise)
  • Route premium customers to premium support

Time-Based Routing

  • Business hours → Full team
  • After hours → Auto-responder + urgent escalation

Real-World Examples

Lead Qualification

  • Cold lead → Nurture campaign
  • Warm lead → Sales rep
  • Hot lead → Account executive

Content Moderation

  • Safe → Auto-publish
  • Questionable → Human review
  • Unsafe → Auto-reject + flag

Document Processing

  • Invoice → Accounting workflow
  • Contract → Legal review
  • Receipt → Expense tracking

Email Triage

  • Internal → Forward to department
  • Customer → Support workflow
  • Sales inquiry → CRM + sales team

Enhancements

Add Sentiment Analysis

  • Route angry customers to senior support
  • Route happy customers to upsell team

Add Language Detection

  • Route to language-specific handlers
  • Auto-translate if needed

Add Load Balancing

  • Track current ticket count per agent
  • Route to least busy agent

Add Learning Loop

  • Track which routes resolve fastest
  • Adjust routing logic based on outcomes

Add Fallback Routing

  • If all handlers busy → queue
  • If handler fails → backup handler

Cost

Per 1,000 routed requests:

  • Classification: ~$0.20 (GPT-4o-mini)
  • Handlers: ~$2-10 (depends on complexity)
  • Total: ~$2.20-10.20

Cost optimization:

  • Use GPT-4o-mini for classification
  • Use stronger models only for complex handlers
  • Cache common responses
Next Step

Combine with Multi-Step Agent for sophisticated handlers that chain specialized agents!