How It Works
Pipecat Cloud implements Plivo’s bidirectional Media Streaming protocol. While audio streams flow through WebSockets, the call session is controlled by XML responses that tell Plivo how to handle each call. When Pipecat Cloud receives an incoming WebSocket connection from Plivo, it processes thestart
message to initialize a new bot instance. All WebSocket messages are forwarded to your bot, including call information such as the caller’s number and call UUID. This allows your bot to leverage Plivo’s Voice API for advanced call control - such as recording conversations, transferring to human agents, or implementing complex call flows.
Prerequisites
Before setting up this integration, ensure you have:- A Plivo account with voice capabilities
- A Pipecat Cloud account with a Plivo WebSocket-compatible bot
- A web server to host XML responses (we’ll show you how to set this up)
Plivo Setup
To connect your Pipecat Cloud bot to Plivo’s voice network:- Purchase a phone number from Plivo if you haven’t already. Ensure the number has voice capabilities.
-
Retrieve your Pipecat Cloud organization name using the
pipecatcloud
CLI. This information is required when creating the XML configuration.
- Set up an XML server to respond to Plivo webhooks. Unlike Twilio’s TwiML Bins, Plivo requires a web server to host your XML responses.
server.py
:
- Install dependencies and run your XML server:
- Make your server publicly accessible. For testing, you can use ngrok:
https://abc123.ngrok.io
.
When testing using ngrok, use a
--subdomain
arg to keep your ngrok URL
consistent.- Create your XML application in the Plivo dashboard:
- Navigate to Voice → XML in your Plivo dashboard
- Select Add New Application
- Enter a name for your application (e.g., “Pipecat WebSocket”)
- Set the Answer URL to your ngrok URL with agent and organization parameters:
- Replace
AGENT_NAME
with your deployed bot’s name (e.g.,my-first-agent
) - Replace
ORGANIZATION_NAME
with your organization name from step 2 (e.g.,three-random-words-randomnumber
)
- Replace
- Set HTTP Method to
GET
- Click Create Application to create your application
- Configure your Plivo phone number to use your XML application:
- Navigate to Phone Numbers and select your phone number from the list
- Select XML Application as the Application Type
- Select your XML Application from the Plivo Application dropdown
- Click Update to apply your changes
Making and Receiving Calls
Receiving Inbound Calls
To test your integration, simply dial your Plivo phone number from any phone. The call will connect to your Pipecat Cloud bot, which will respond according to your bot’s configuration.Advanced Call Control
Your bot can control the active call by leveraging Plivo’s Voice API with theCallUUID
that’s automatically provided to your bot. This enables capabilities such as:
- Recording conversations
- Playing audio prompts
- Gathering DTMF input (keypad presses)
- Ending calls programmatically