Overview
WhatsAppTransport enables real-time voice conversations between WhatsApp users and your Pipecat bot through the WhatsApp Business API. When users call your WhatsApp Business number, the transport handles webhook events, establishes WebRTC connections, and manages the voice call lifecycle. The transport integrates with Meta’s WhatsApp Cloud API to receive incoming calls, process WebRTC signaling, and maintain call state throughout the conversation.WhatsApp API Reference
API methods for Pipecat’s WhatsApp Cloud API integration
WhatsApp Client Reference
Pipecat’s Client for handling webhooks and WebRTC connections
Example Implementation
Complete WhatsApp voice bot example
WhatsApp Business API Docs
Meta’s official WhatsApp calling documentation
Installation
To use WhatsAppTransport, install the required dependencies:Prerequisites
WhatsApp Business API Setup
Before using WhatsAppTransport, you need:- WhatsApp Business API Account: Set up through Meta Developer Console
- Phone Number Configuration: Enable voice calling capability for your business number
- Webhook Configuration: Configure webhook endpoint to receive call events
- Access Tokens: Generate API access token and phone number ID
Required Environment Variables
WHATSAPP_TOKEN: WhatsApp Business API access tokenWHATSAPP_PHONE_NUMBER_ID: Your business phone number IDWHATSAPP_WEBHOOK_VERIFICATION_TOKEN: Token for webhook verification
Key Features
- Incoming Call Handling: Automatically accepts WhatsApp voice calls
- WebRTC Integration: Establishes peer-to-peer audio connections
- Webhook Processing: Handles Meta’s webhook events for call lifecycle
- Call Management: Supports call acceptance, rejection, and termination
- Real-time Audio: Bidirectional audio streaming for natural conversations
Configuration
WhatsAppClient
WhatsAppClient is the main class for handling WhatsApp call connections. It manages webhook processing, WebRTC connection establishment, and call lifecycle.
WhatsApp Business API access token for authentication.
WhatsApp Business phone number ID.
An aiohttp session for making async HTTP requests to the WhatsApp Cloud API.
List of ICE servers for WebRTC connections. If
None, defaults to Google’s public STUN server (stun:stun.l.google.com:19302).WhatsApp App Secret for validating that webhook requests came from WhatsApp. When set, all incoming webhooks are verified using HMAC SHA-256 signature validation.
Usage
WhatsAppTransport requires a webhook server to handle incoming calls and a bot implementation to process the conversations. The transport works withSmallWebRTCTransport under the hood for WebRTC connectivity.
The WhatsAppClient handles the WhatsApp-specific webhook processing and call management, while the actual audio transport uses a SmallWebRTCConnection for each call.
See the complete example for a full implementation including:
- FastAPI webhook server with verification endpoint
- WhatsApp client configuration
- Bot integration with Pipecat pipeline using
SmallWebRTCTransport - Environment setup and deployment
Notes
- WhatsApp only supports SHA-256 fingerprints in SDP, so the client automatically filters out other fingerprint types.
- Each incoming call creates a new
SmallWebRTCConnectionthat can be used withSmallWebRTCTransport. - The client supports both
pre_acceptandacceptcall flow as required by the WhatsApp Cloud API. - Use
terminate_all_calls()during shutdown to cleanly end all ongoing calls.
Additional Resources
- Events Overview - Overview of all events in Pipecat
- SmallWebRTCTransport - The underlying transport used for WebRTC connectivity
- WhatsApp Cloud API Calling Docs - Official WhatsApp calling documentation