Documentation Index
Fetch the complete documentation index at: https://docs.zapthinker.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Router & Handoff system provides intelligent message routing to direct conversations to the appropriate bot or human agent based on configurable rules. It includes AI-powered classification, keyword matching, and seamless human handoff capabilities for complex queries that require human intervention.Key Features
- Rule-Based Routing: Define rules to route messages to specific bots
- AI Classification: Automatic message categorization using LLM models
- Priority System: Control rule execution order
- Human Handoff: Seamlessly transfer conversations to human agents
- Session Management: Track active handoff sessions
- Conversation Notes: Add internal notes for agent context
- Conversation Summary: AI-generated summaries of chat history
- Routing Logs: Complete audit trail of routing decisions
- Statistics: Analytics on routing performance
How It Works
Message Routing Flow
- Message Received: New message arrives from user
- Rule Evaluation: System evaluates routing rules in priority order
- Condition Matching: Checks keywords, AI categories, or custom logic
- Bot Selection: Routes to the matched bot
- Response Generation: Selected bot processes and responds
- Logging: Decision logged for analytics
Human Handoff Flow
- Handoff Trigger: User requests human agent or bot escalates
- Session Creation: Handoff session created with conversation context
- Agent Notification: Human agent receives notification
- Agent Takes Over: Agent claims the conversation
- Direct Communication: Messages bypass bots and go to agent
- Session Close: Agent marks conversation as resolved
Routing Rules
Rule Structure
Condition Types
Keyword Matching
Route based on specific words or phrases:- Contains: Message contains any/all keywords
- Exact Match: Message exactly matches keyword
- Regex: Advanced pattern matching
AI Classification
Use AI to categorize messages:- Categories: Define custom categories (sales, support, billing, etc.)
- Confidence Threshold: Minimum confidence for classification
- Model Selection: Choose LLM model for classification
Time-Based
Route based on time of day or day of week:- Business Hours: Route to bots during business hours
- After Hours: Route to different bot or auto-responder
User-Based
Route based on user attributes:- VIP Customers: Priority routing for important customers
- New Users: Special onboarding flow
- Returning Users: Context-aware routing
Human Handoff
Taking Over Conversations
Agents can take over conversations in several ways:- Manual Takeover: Agent claims conversation from queue
- Bot Escalation: Bot automatically escalates complex queries
- User Request: User explicitly asks for human agent
- Timeout: Conversation idle for too long
Handoff Features
Session Status
- Active: Agent is handling conversation
- Waiting: Waiting for agent to claim
- Resolved: Conversation completed
- Transferred: Moved to another agent
Conversation Context
- Full message history
- User information
- Previous bot interactions
- AI-generated summary
Internal Notes
Agents can add notes visible only to other agents:- Customer context
- Issue details
- Resolution steps
- Follow-up requirements
Conversation Summary
AI-generated summaries provide quick context:- Key topics discussed
- User sentiment
- Issues raised
- Actions taken
Releasing Conversations
When agent completes handling:- Add final notes
- Mark as resolved
- Release back to bot routing
- Conversation history preserved
AI Classification
How It Works
- Message Analysis: LLM analyzes message content
- Category Matching: Compares against defined categories
- Confidence Scoring: Assigns confidence to each category
- Threshold Check: Only routes if confidence exceeds threshold
- Fallback: Uses keyword matching if AI classification fails
Category Definition
Supported Models
- Groq Models: Fast, cost-effective classification
- OpenAI GPT: High accuracy classification
- Custom Models: Integrate your own classification API
Routing Logs
Track every routing decision:- Timestamp: When decision was made
- Message Content: What triggered the routing
- Rules Evaluated: Which rules were checked
- Matched Rule: Which rule was selected
- Target Bot: Where message was routed
- Confidence: AI classification confidence (if applicable)
Log Queries
Filter logs by:- Date range
- Specific bot
- Rule name
- User/conversation
- Success/failure status
Statistics
Monitor routing performance:- Total Messages Routed: Volume over time
- Bot Distribution: Which bots receive most messages
- Rule Performance: Which rules match most often
- AI Accuracy: Classification confidence trends
- Handoff Metrics: Average resolution time, agent utilization
- Fallback Rate: How often default routing is used
Use Cases
Multi-Department Support
Route customer queries to sales, support, or billing bots based on intent.Tiered Support
Start with automated bot, escalate to human for complex issues.Language Routing
Route to language-specific bots based on detected language.Product-Specific Routing
Direct questions to specialized bots for different products.VIP Customer Handling
Automatically route VIP customers to human agents.Best Practices
- Clear Categories: Define distinct, non-overlapping categories
- Priority Order: Set priorities to handle edge cases
- Testing: Use test mode to validate rules before deployment
- Monitoring: Regularly review routing logs and statistics
- Fallback Strategy: Always have a default route
- Agent Training: Ensure agents understand handoff workflow
- Response Time: Set expectations for human response times
- Conversation Notes: Encourage detailed note-taking
Testing Rules
Test rules before deployment:- Which rules matched
- Which bot would be selected
- Confidence scores
- Execution path
Advanced Features
Context Stickiness
Keep users with the same bot across multiple messages:- Configurable timeout
- Explicit context reset
- Cross-session memory
Conditional Routing
Complex conditions using AND/OR logic:- Multiple keyword groups
- Combined AI + keyword matching
- Time-based overrides
A/B Testing
Test different routing strategies:- Split traffic between bots
- Compare performance metrics
- Gradual rollout of new rules
Webhook Integration
Trigger external systems on routing events:- CRM updates
- Analytics tracking
- Custom notifications
Getting Started
- Define your routing categories
- Create routing rules with priorities
- Test rules with sample messages
- Deploy to production
- Monitor logs and statistics
- Refine rules based on performance
- Configure human handoff workflow
- Train agents on handoff system

