Overview
TelnyxFrameSerializer enables integration with Telnyx’s WebSocket media streaming protocol, allowing your Pipecat application to handle phone calls via Telnyx’s voice services with bidirectional audio conversion, DTMF event handling, and support for multiple audio encodings.
Telnyx Serializer API Reference
Pipecat’s API methods for Telnyx WebSocket integration
Example Implementation
Complete telephony examples with Telnyx
Telnyx Documentation
Official Telnyx media streaming documentation
Telnyx Portal
Manage phone numbers and streaming configuration
Installation
TheTelnyxFrameSerializer does not require any additional dependencies beyond the core Pipecat library:
Prerequisites
Telnyx Account Setup
Before using TelnyxFrameSerializer, you need:- Telnyx Account: Sign up at Telnyx Portal
- Phone Number: Purchase a Telnyx phone number with voice capabilities
- Media Streaming: Configure your phone number for WebSocket streaming
- Webhook Configuration: Set up webhook endpoints for call handling
Required Environment Variables
TELNYX_API_KEY: Your Telnyx API key for authentication and call control
Required Configuration
- Stream ID: Provided by Telnyx during WebSocket connection
- Audio Encodings: Configure inbound/outbound encodings (PCMU, PCMA)
- Call Control ID: Required for automatic call termination (optional)
Key Features
- Bidirectional Audio: Convert between Pipecat and Telnyx audio formats
- DTMF Handling: Process touch-tone events from callers
- Auto Hang-up: Terminate calls via Telnyx’s REST API
- Multiple Encodings: Support for PCMU and PCMA audio formats
Configuration
The Telnyx Stream ID.
The encoding type for outbound audio received from Telnyx (e.g.,
"PCMU", "PCMA").The encoding type for inbound audio sent to Telnyx (e.g.,
"PCMU", "PCMA").The Telnyx Call Control ID. Required when
auto_hang_up is enabled.Telnyx API key. Required when
auto_hang_up is enabled.Configuration parameters for audio and hang-up behavior. See InputParams below.
InputParams
| Parameter | Type | Default | Description |
|---|---|---|---|
telnyx_sample_rate | int | 8000 | Sample rate used by Telnyx (Hz). |
sample_rate | int | None | Optional override for pipeline input sample rate. When None, uses the pipeline’s configured rate. |
inbound_encoding | str | "PCMU" | Audio encoding for data sent to Telnyx. |
outbound_encoding | str | "PCMU" | Audio encoding for data received from Telnyx. |
auto_hang_up | bool | True | Whether to automatically terminate the call on EndFrame or CancelFrame. |
Usage
Basic Setup
Without Auto Hang-up
Notes
- Multiple audio encodings: Telnyx supports both PCMU (mu-law) and PCMA (A-law) encodings. The
inbound_encodingandoutbound_encodingmust be specified as constructor arguments and will override any values set inInputParams. - Auto hang-up credentials: When
auto_hang_upis enabled (the default),call_control_idandapi_keyare required to terminate the call via Telnyx’s REST API. If missing, a warning is logged and the hang-up is skipped. - DTMF support: Touch-tone digit events from callers are converted to
InputDTMFFrameobjects.