Pipecat
This guide shows how to integrate the AgentDuet SDK with Pipecat pipelines using the pipecat-agentduet transport package.
What this integration provides
A telephony transport (AgentDuetTransport) that moves live audio and call lifecycle events between an AgentDuet phone or WhatsApp call and any Pipecat pipeline.
Unlike traditional telephony setups in Pipecat (which require provisioning public endpoints, running FastAPI webhook servers, setting up ngrok tunnels, and configuring media frame serializers), the AgentDuet SDK connects outbound to the AgentDuet platform. Calls are delivered down that persistent connection automatically.
Key Features
- Zero Webhook Hosting: No public URLs, ngrok, or reverse proxies required.
- Native PCM Audio: Streams mono 16-bit PCM at the line rate (8 kHz, 16 kHz, or 24 kHz) with no manual audio transcoding.
- Unified Event Lifecycle: Automatic call answering on pipeline start, cleanup on pipeline completion, and cancellation on remote hangup.
- Built-in Barge-in: Fully compatible with Pipecat’s VAD and turn processing for interruption handling.
Prerequisites
- Python 3.12+
- An API key and connector UUID from agentduet.com
- A Deepgram API Key (used for STT and TTS)
- A Google AI Studio API Key (used for Gemini LLM)
Step 1: Create a project folder
Step 2: Configure .env
Create a .env file in your project directory:
Step 3: Write voice_bot.py
Create voice_bot.py next to .env:
Step 4: Run the bot
Start your voice bot:
Call your AgentDuet provisioned phone number or WhatsApp number. The bot answers automatically, greets you, and carries on a real-time voice conversation with interruption support.
Event Lifecycle
You can hook into call lifecycle events on the AgentDuetTransport instance using @transport.event_handler(event_name):
Audio Architecture
AgentDuetTransport reads the call’s audio configuration directly from the AgentDuet Call object (mono 16-bit PCM at 8 kHz, 16 kHz, or 24 kHz) and provisions the pipeline input/output streams to match.
Pipecat automatically manages intermediate resampling between services (such as TTS output rates and STT input rates), ensuring audio crosses between the telephony network and your pipeline cleanly.
