Unified runner for building voice AI bots with Daily, WebRTC, and telephony transports
run_bot()
function contains your actual bot logic and is transport-agnostic. The bot()
function is the entry point that the runner calls - it creates the appropriate transport and passes it to your bot logic. This separation allows the same bot code to work across different transports.
When you run this with python bot.py
, the development runner starts a web server and opens a browser interface at http://localhost:7860/client
. Each time someone connects, the runner calls your bot()
function with WebRTC runner arguments.
DailyRunnerArguments
: Contains room_url
and token
for joining Daily roomsSmallWebRTCRunnerArguments
: Contains webrtc_connection
for local WebRTC sessionsWebSocketRunnerArguments
: Contains websocket
for telephony connectionsfrom pipecat.transports.services.daily import ...
) inside the conditional blocks. This ensures that transport-specific dependencies are only required when that transport is actually used, making your bot more portable.
RunnerArguments
is the base class for all runner arguments. It provides a
common interface for the runner to pass transport-specific information to your
bot.ENV
environment variable to help with this:
ENV=local
(set by the development runner)ENV
is not set or has a different value-t webrtc
)SmallWebRTCRunnerArguments
webrtc_connection
: Pre-configured WebRTC peer connection-t daily
)DailyRunnerArguments
room_url
: Daily room URL to jointoken
: Authentication token for the roombody
: Additional request data-t twilio|telnyx|plivo
)WebSocketRunnerArguments
websocket
: WebSocket connection for audio streaming--transport
/ -t
: Determines which transport infrastructure to set up
webrtc
: Local WebRTC with browser interfacedaily
: Daily.co integration with room managementtwilio
, telnyx
, plivo
: Telephony provider integration--proxy
/ -x
: Required for telephony transports. This should be a publicly accessible hostname (like yourbot.ngrok.io
) that can receive webhooks from telephony providers.
--direct
/ -d
: Special mode for Daily that bypasses the web server and connects your bot directly to a Daily room. Useful for quick testing but not recommended for production use.
--esp32
: Enables SDP (Session Description Protocol) modifications needed for ESP32 WebRTC compatibility. Must be used with a specific IP address via --host
.
DAILY_API_KEY
: Daily API key for creating rooms and tokensDAILY_SAMPLE_ROOM_URL
(optional): Existing room URL to useTWILIO_ACCOUNT_SID
, TWILIO_AUTH_TOKEN
: Twilio credentialsPLIVO_AUTH_ID
, PLIVO_AUTH_TOKEN
: Plivo credentialsTELNYX_API_KEY
: Telnyx API keycreate_transport
utility provides a much cleaner way to handle multiple transports. Instead of writing conditional logic for each transport type, you define transport configurations upfront and let the utility handle the selection:
bot()
function.
Transport | Command | Access |
---|---|---|
WebRTC | python bot.py | http://localhost:7860/client |
Daily | python bot.py -t daily | http://localhost:7860 |
Daily Direct | python bot.py -d | Direct connection |
Twilio | python bot.py -t twilio -x proxy.ngrok.io | Phone calls |
Telnyx | python bot.py -t telnyx -x proxy.ngrok.io | Phone calls |
Plivo | python bot.py -t plivo -x proxy.ngrok.io | Phone calls |
ESP32 WebRTC | python bot.py -t webrtc --esp32 --host <ESP32_IP> | ESP32 WebRTC connection |