Anonymous Login for AI Agents
Overview
TheanonymousLogin method allows you to connect to AI assistants without traditional authentication credentials. This is the first step in establishing communication with a Telnyx AI Agent.
Method Signature
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
targetId | String | Yes | - | The ID of your AI assistant |
targetType | String | No | ’ai_assistant’ | The type of target |
targetVersionId | String? | No | null | Optional version ID of the target. If not provided, uses latest version |
userVariables | Map<String, dynamic>? | No | null | Optional user variables to include |
reconnection | bool | No | false | Whether this is a reconnection attempt |
logLevel | LogLevel | No | LogLevel.none | Log level for this session |
Usage Example
Advanced Usage
With User Variables
With Logging
Important Notes
- Call Routing: After a successful
anonymousLogin, any subsequent call, regardless of the destination, will be directed to the specified AI Assistant - Session Lock: The session becomes locked to the AI assistant until disconnection
- Version Control: If
targetVersionIdis not provided, the SDK will use the latest available version - Error Handling: Always wrap the call in a try-catch block to handle authentication errors
Error Handling
Common errors you might encounter:Next Steps
After successful anonymous login:- Start a conversation using
newInvite() - Set up transcript updates to receive real-time conversation data
- Send text messages during active calls