The Pattern
Not all inputs should be handled the same way. A routing pattern uses one prompt to classify the input, then directs it to the right specialized prompt based on that classification.
The flow: Input → Classifier Prompt → Category → Specialized Handler Prompt
Example: Customer Support Router
Here's how you might route customer messages to specialized response handlers:
- BILLING: Payment issues, refunds, subscription questions
- TECHNICAL: Product bugs, how-to questions, feature requests
- SHIPPING: Delivery status, address changes, lost packages
- OTHER: Anything else
Customer message: "I was charged twice for my subscription this month and I need a refund for the duplicate charge."
Respond with only the category name.
- Duplicate charges are refunded within 3-5 business days
- Refunds go to original payment method
- Customer can also get account credit (instant) instead
Respond to this billing issue with empathy. Acknowledge the problem, explain the solution, and offer options.
Customer message: "I was charged twice for my subscription this month and I need a refund for the duplicate charge."
I can process a refund for the duplicate charge right away. You have two options:
1. Refund to your original payment method — typically takes 3-5 business days.
2. Instant account credit — applied to your next billing cycle immediately.
Which would you prefer?
Why Routing Works
A single prompt that tries to handle everything becomes bloated and unfocused. Specialized prompts can include domain-specific context, policies, tone, and examples that wouldn't fit in a general-purpose prompt.
The classifier prompt stays simple — its only job is categorization. The handler prompts can go deep on their specific domain.
This is like having specialists instead of generalists. A billing expert knows refund policies. A technical expert knows troubleshooting steps.
The Technique
First, ask AI to classify the input into categories. Then, based on the classification, use a different specialized prompt for each category. Each handler is an expert in its domain.
When to Route
- • Different inputs need different expertise or context
- • You have distinct categories with different handling rules
- • A single prompt would be too long with all the specialized knowledge
- • Different categories need different tones or formats
- • You want to optimize each path independently
Making Classification Reliable
The classifier prompt is critical. Make categories mutually exclusive and provide clear examples. Ask for just the category name — nothing else — so you can easily use the response.
Consider adding an "OTHER" or "UNKNOWN" category for inputs that don't fit. This prevents forcing bad fits and lets you handle edge cases gracefully.