Skip to main content

Starting Conversations with AI Assistants

Overview

After a successful anonymousLogin, 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 destinationNumber parameter 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-Context header maps to {{session_context}} variable.

Basic Example

Advanced Usage

With Custom Headers

Note: The above headers will map to dynamic variables {{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

  1. State Management: Always set up call state listeners before initiating the call
  2. Error Handling: Implement proper error handling for connection failures
  3. Resource Cleanup: Ensure calls are properly ended to free resources
  4. User Feedback: Provide clear UI feedback about connection status
  5. Debugging: Use debug mode during development to monitor call quality

Next Steps

After starting a conversation:
  1. Set up transcript updates to receive real-time conversation data
  2. Send text messages during the active call
  3. Use standard call controls as needed