Best Practices
Best Practices
Guidelines and recommendations for building production-quality SignalWire voice AI agents.
Overview
Prompt Design
Use POM (Prompt Object Model)
Structure prompts with clear sections:
Be Specific About Behavior
Function Design
Clear Descriptions
Return Actionable Information
Error Handling
Graceful Degradation
Security
Use Authentication
Secure Function Flag
The secure=True flag pauses call recording during function execution. This is useful for sensitive operations but does not prevent data from reaching the LLM.
Secure Payment Processing
For payment card collection, never collect card data through SWAIG function parameters. Use the .pay() method instead, which collects card data via IVR and sends it directly to your payment gateway—the LLM never sees the card number, CVV, or expiry.
Environment Variables
Performance
Use DataMap for Simple API Calls
Use Fillers for Long Operations
Testing
Use swaig-test
Monitoring
Use Structured Logging
Production Readiness Checklist
- Authentication configured (basic_auth or environment variables)
- SSL/HTTPS enabled for production
- Sensitive functions marked as secure
- Error handling in all functions
- Input validation for user-provided data
- Logging configured (no sensitive data in logs)
- All functions tested with swaig-test
- Edge cases and error scenarios tested
- Prompts reviewed for clarity and completeness
- Transfer/escalation paths defined
- Timeout values appropriate for use case
- Summary handling for call analytics