Philosophy
Iqra AI maintains a clear separation:- AI layer - Handles natural language understanding and generation (probabilistic)
- Deterministic layer - Handles business logic, data validation, and workflow control (guaranteed)
Core concepts
Variables as state
Variables are the foundation of deterministic control. Unlike AI memory (which is fuzzy), variables store exact values:- Type safety - String, Number, or Boolean
- Visibility control - Show/hide from AI
- Edit permissions - AI-editable or read-only
- Template access - Use in Scriban templates
System tools as actions
System tools are deterministic operations that modify state or control flow:- DTMF Input - Collect exact keypad digits
- Go To Node - Jump to specific conversation points
- End Call - Terminate with certainty
- Send SMS - Guaranteed message delivery
- Add Script - Dynamic context loading
Conditional routing
Edges between nodes can represent different outcomes, creating if/else logic:Common patterns
If/else branching
Implement conditional logic using DTMF outcomes or Custom Tool responses. Example: Menu selection1
Present options
2
Collect input
3
Execute path
Each outcome connects to a different workflow branch that executes deterministically.
Loops and retries
Use Go To Node to create retry logic for failed operations. Example: PIN verification with retry limit- Variable tracking (
pin_attempts) - Conditional checking (attempts < max)
- Loop back (Go To Node)
- Exit condition (End Call)
State machines
Model complex workflows as states and transitions. Example: Payment processingDynamic script loading
Load different conversation modules based on runtime conditions. Example: Tier-based supportData validation pipeline
Chain multiple validation steps before processing. Example: Email verificationTemplate logic
Use Scriban templates in AI Response nodes for dynamic content generation.Conditional messages
Loops in templates
Math operations
Scriban templates execute during the AI Response generation phase, allowing you to compute values before speaking them.
Best practices
Separate concerns
- Good
- Bad
Use variables for decisions
Don’t ask the AI to make business decisions:- Good
- Bad
Handle all edge cases
Every DTMF Input and Custom Tool should have:- Success path
- Failure path
- Timeout path (if applicable)
- Maximum retry logic
Keep loops bounded
Always have an exit condition:Log state transitions
Use variables to track workflow progress:Advanced patterns
Saga pattern for distributed workflows
When integrating multiple external systems, implement compensating actions:Rate limiting
Track API call counts to avoid exceeding limits:A/B testing flows
Randomly route users to different experiences:Debugging flows
Use descriptive variable names
Add checkpoint nodes
Insert AI Response nodes that speak variable values during testing:Log to variables
Create adebug_log variable and append to it:
Performance considerations
Minimize tool calls
Batch operations when possible:- Optimized
- Slow
Cache computed values
Don’t recalculate in templates:Lazy-load scripts
Only add scripts when needed:Next steps
Script nodes
Learn about all available node types
Secure sessions
PCI-DSS compliant data collection
Custom tools
Integrate your backend APIs