Skip to main content

Overview

PlivoFrameSerializer enables integration with Plivo’s Audio Streaming WebSocket protocol, allowing your Pipecat application to handle phone calls via Plivo’s voice services with bidirectional audio conversion, DTMF event handling, and automatic call termination.

Installation

The PlivoFrameSerializer does not require any additional dependencies beyond the core Pipecat library:
pip install "pipecat-ai"

Prerequisites

Plivo Account Setup

Before using PlivoFrameSerializer, you need:
  1. Plivo Account: Sign up at Plivo Console
  2. Phone Number: Purchase a Plivo phone number with voice capabilities
  3. Audio Streaming: Configure your phone number for WebSocket streaming
  4. Webhook Configuration: Set up webhook endpoints for call handling

Required Environment Variables

  • PLIVO_AUTH_ID: Your Plivo Auth ID for authentication
  • PLIVO_AUTH_TOKEN: Your Plivo Auth Token for API operations

Required Configuration

  • Stream ID: Provided by Plivo during Audio Streaming connection
  • Call ID: Required for automatic call termination (optional)

Key Features

  • Bidirectional Audio: Convert between Pipecat and Plivo audio formats
  • DTMF Handling: Process touch-tone events from callers
  • Auto Hang-up: Terminate calls via Plivo’s REST API
  • μ-law Encoding: Handle Plivo’s standard audio encoding format

Configuration

stream_id
str
required
The Plivo Stream ID.
call_id
str
default:"None"
The associated Plivo Call ID. Required when auto_hang_up is enabled.
auth_id
str
default:"None"
Plivo auth ID. Required when auto_hang_up is enabled.
auth_token
str
default:"None"
Plivo auth token. Required when auto_hang_up is enabled.
params
InputParams
default:"None"
Configuration parameters for audio and hang-up behavior. See InputParams below.

InputParams

ParameterTypeDefaultDescription
plivo_sample_rateint8000Sample rate used by Plivo (Hz).
sample_rateintNoneOptional override for pipeline input sample rate. When None, uses the pipeline’s configured rate.
auto_hang_upboolTrueWhether to automatically terminate the call on EndFrame or CancelFrame.
ignore_rtvi_messagesboolTrueWhether to ignore RTVI protocol messages during serialization.

Usage

Basic Setup

from pipecat.serializers.plivo import PlivoFrameSerializer
from pipecat.transports.network.websocket_server import WebSocketServerTransport

serializer = PlivoFrameSerializer(
    stream_id=stream_id,
    call_id=call_id,
    auth_id=os.getenv("PLIVO_AUTH_ID"),
    auth_token=os.getenv("PLIVO_AUTH_TOKEN"),
)

transport = WebSocketServerTransport(
    params=WebSocketServerParams(
        audio_out_enabled=True,
        add_wav_header=False,
        serializer=serializer,
    )
)

Without Auto Hang-up

serializer = PlivoFrameSerializer(
    stream_id=stream_id,
    params=PlivoFrameSerializer.InputParams(
        auto_hang_up=False,
    ),
)

Notes

  • Auto hang-up credentials: When auto_hang_up is enabled (the default), the serializer uses call_id, auth_id, and auth_token to terminate the call via Plivo’s REST API. If any are missing, a warning is logged and the hang-up is skipped.
  • Audio format: Plivo uses 8kHz mu-law (PCMU) audio encoding. The serializer automatically converts between this format and Pipecat’s PCM audio.
  • DTMF support: Touch-tone digit events from callers are converted to InputDTMFFrame objects.