Dialog Rails
Dialog rails execute during multi-turn conversations to enforce flow logic, steer dialogs, and apply policies across the entire interaction. Unlike input/output rails that check individual messages, dialog rails manage the conversation state and structure.When Dialog Rails Execute
Dialog rails run throughout the conversation lifecycle:Dialog rails use Colang flows to define conversation patterns, topic boundaries, and state management.
Key Concepts
Conversation Flows
Flows define the allowed patterns of interaction:Topic Control
Restrict conversations to allowed topics:Disallowed Topics
Block specific conversation topics:Built-in Dialog Rails
Flow Management
Control the progression of conversations:State Management
Track conversation state across turns:Policy Enforcement
Apply business rules throughout the conversation:Common Patterns
Guided Conversations
Lead users through structured interactions:Context Tracking
Maintain conversation context:Conditional Flows
Adapt based on conversation state:Advanced Dialog Rails
Subflows
Reusable conversation components:Event Handling
Respond to system events:Multi-Intent Handling
Manage complex user inputs:Integration with Other Rails
Conditional Input Rails
Apply input rails based on dialog state:Conditional Output Rails
Validate outputs based on topic:Real-World Examples
Customer Support Flow
Educational Tutoring
Compliance Enforcement
Configuration
Enable Dialog Rails
Dialog rails are enabled by defining flows in.co files:
Flow Priority
Control which flows take precedence:Best Practices
- Keep flows focused - Each flow should handle a single conversation pattern
- Use subflows for reusability - Extract common patterns into reusable subflows
- Handle edge cases - Always provide fallback flows for unexpected inputs
- Track important state - Use variables to maintain conversation context
- Test flow coverage - Ensure all user intents have corresponding flows
- Document flow logic - Add comments explaining complex flow decisions
Limitations
Performance Considerations
- Flow matching overhead - Complex flow definitions add latency
- State management - Tracking many variables increases memory usage
- Intent recognition - LLM calls for intent matching add cost
Debugging Dialog Rails
Enable verbose logging:- Flow matching decisions
- State variable changes
- Event triggers
See Also
- Colang Language Reference - Full language syntax
- Input Rails - Message-level validation
- Output Rails - Response filtering
- Execution Rails - Tool call security