Starting Conversations with AI Assistants
Overview
After a successfulanonymousLogin, you can initiate a call to your AI Assistant using the newInvite method. The AI assistant will automatically answer the call, and standard call controls will work normally.
Method Usage
Important Behavior
- Destination Ignored: Because the session is locked to the AI Assistant, the
destinationNumberparameter is ignored, but can still be useful for referencing logs. - Automatic Answer: The AI assistant automatically answers the call
- Standard Controls: All normal call controls (mute, hold, end, etc.) work as expected
- Custom Headers: You can pass custom SIP headers to provide context to the AI assistant. They will be mapped to dynamic variables in the portal. Hyphens in header names are converted to underscores in variable names, e.g.
X-Session-Contextheader maps to{{session_context}}variable.
Basic Example
Advanced Usage
With Custom Headers
{{session_context}} and {{user_tier}} in the AI assistant portal settings
With Preferred Audio Codecs
With Debug Mode
Call State Management
The AI call follows the same state management as regular calls:Call Control Examples
Mute/Unmute
Hold/Unhold
Speaker Phone
End Call
Error Handling
Best Practices
- State Management: Always set up call state listeners before initiating the call
- Error Handling: Implement proper error handling for connection failures
- Resource Cleanup: Ensure calls are properly ended to free resources
- User Feedback: Provide clear UI feedback about connection status
- Debugging: Use debug mode during development to monitor call quality
Next Steps
After starting a conversation:- Set up transcript updates to receive real-time conversation data
- Send text messages during the active call
- Use standard call controls as needed