Skip to main content

Anonymous Connection for AI Agents

Overview

The connectAnonymously 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

Usage Example

Advanced Usage

With User Variables

With Version Control

With Custom Server Configuration

Important Notes

  • Call Routing: After a successful anonymous connection, 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 targetVersionId is not provided, the SDK will use the latest available version
  • Error Handling: Monitor socket responses for authentication errors
  • Server Configuration: Custom server configuration can be provided through the providedServerConfig parameter

Socket Response Handling

Listen for connection responses using the socket response flow:

Error Handling

Common errors you might encounter:

Next Steps

After successful anonymous connection:
  1. Start a conversation using newInvite()
  2. Set up transcript updates to receive real-time conversation data
  3. Send text messages during active calls