Use this file to discover all available pages before exploring further.
Telnyx is a global connectivity platform that provides programmable voice, messaging, and wireless services. By combining Telnyx with AssemblyAI, you can build real-time voice agents with industry-leading speech recognition accuracy and advanced turn detection.This guide shows you how to integrate Telnyx with AssemblyAI using two popular voice agent orchestrators: LiveKit and Pipecat.
LiveKit is a real-time communication platform for building voice, video, and data applications. You can integrate Telnyx SIP trunking with LiveKit to enable phone calls to your voice agents that use AssemblyAI for speech recognition.
Telnyx SIP trunks bridge phone calls into LiveKit rooms as special SIP participants. Your LiveKit agent (configured with AssemblyAI STT) connects to the room and interacts with the caller. The flow is:
Create a LiveKit agent that uses AssemblyAI for speech recognition. Once your SIP trunks and dispatch rules are configured, no special telephony code is required—the agent simply joins the room when a call comes in.
Now dial your Telnyx phone number to test the integration. The call will be routed through Telnyx → LiveKit → your agent with AssemblyAI speech recognition.
Call connects but agent never speaks: Verify your dispatch rule includes roomConfig.agents with the correct agentName. Without this, the agent won’t be automatically dispatched to the room.Audio quality issues: Check your Telnyx SIP connection settings and ensure proper codec configuration. See the Telnyx troubleshooting guide.
Pipecat is an open-source framework for building voice and multimodal conversational AI agents. You can integrate Telnyx Media Streaming with Pipecat to enable phone calls to your voice agents that use AssemblyAI for speech recognition.This guide covers both dial-in (users call your number) and dial-out (your bot calls users) functionality.
Telnyx account: Create an account and purchase phone numbers at telnyx.com
Public server or tunnel: For dial-out, you’ll need a public-facing server or tunneling service like ngrok
API keys: Get API keys for AssemblyAI, OpenAI (or other LLM), and your preferred TTS service
Install the required dependencies:
pip install pipecat-ai python-dotenv loguru
Set up your environment variables:
TELNYX_API_KEY=your_telnyx_api_keyASSEMBLYAI_API_KEY=your_assemblyai_api_keyOPENAI_API_KEY=your_openai_api_keyDEEPGRAM_API_KEY=your_deepgram_api_key # or other TTS provider
Telnyx uses TeXML (Telnyx Extensible Markup Language) to control call flow. Create a TeXML application that establishes a WebSocket connection to your bot:
The bidirectionalMode="rtp" parameter enables real-time audio streaming in both directions.Custom data with query parameters: You can pass custom data to your bot by adding query parameters to the WebSocket URL:
The dial-out bot configuration is similar to dial-in. Telnyx automatically provides call information in the WebSocket messages:
# Parse WebSocket data (same as dial-in)transport_type, call_data = await parse_telephony_websocket(websocket)# Extract call informationstream_id = call_data["stream_id"]call_control_id = call_data["call_control_id"]from_number = call_data["from"] # Your Telnyx numberto_number = call_data["to"] # Target number you're calling# Customize bot behavior for outbound callsgreeting = f"Hi! This is an automated call from {from_number}. How are you today?"
The transport and pipeline configuration are identical to dial-in. See the complete dial-out example for full server implementation with outbound call creation.
Built-in call information: Unlike other providers, Telnyx automatically includes caller information (to/from numbers) in the WebSocket messages, eliminating the need for custom webhook servers in basic dial-in scenarios.