Prerequisites
Required Accounts
Plivo Account- Sign up at https://www.plivo.com/
- Verify your account and add payment method
- Purchase a phone number (for both inbound and outbound calls)
- Sign up at https://daily.co/
- Get your API key from the dashboard
- Daily provides free tier for development
- Ensure that SIP dial-out is enabled. You may have to reach out to Daily support to enable this.
- OpenAI: Get API key from https://platform.openai.com/api-keys
- Deepgram: Sign up at https://deepgram.com/ and get API key
- Cartesia: Sign up at https://cartesia.ai/ and get API key
Required Software
- Python 3.10 or higher
uvpackage manager- ngrok (for local development webhooks)
- Git (for cloning the repository)
Account Setup
1. Plivo Setup
- Log into your Plivo dashboard
- Navigate to Phone Numbers → Buy Numbers
- Select a number with voice capabilities
- Note your Auth ID and Auth Token from the dashboard
- For inbound calls, you’ll configure the answer URL later
2. Daily Setup
- Log into your Daily dashboard
- Navigate to Developers → API Keys
- Create a new API key or use an existing one
- Copy the API key (you’ll need this for
.env)
3. AI Services Setup
OpenAI:- Create account at https://platform.openai.com/
- Navigate to API Keys section
- Create a new secret key
- Copy the key (starts with
sk-)
- Sign up at https://deepgram.com/
- Navigate to API Keys
- Create a new API key
- Copy the key
- Sign up at https://cartesia.ai/
- Navigate to API Keys
- Create a new API key
- Copy the key
Project Setup
1. Clone or Download the Repository
2. Choose Your Project
You have two options:- Outbound Calls:
outbound-call/- For initiating calls - Inbound Calls:
inbound-call/- For receiving calls
3. Install Dependencies
Usinguv:
4. Configure Environment Variables
- Copy the example environment file:
- Edit
.envand fill in your credentials:
.env file to git. It contains sensitive credentials.
Configuration
For Outbound Calls
- Expose your local server using ngrok (required for Plivo webhooks):
-
Copy the HTTPS URL from ngrok (e.g.,
https://abc123.ngrok.io) -
Update the
SERVER_URLin your.envfile:
- Start the server:
-
The server will run on
http://localhost:8000and use the ngrok URL for webhooks -
For production, you’ll need to:
- Set up a public HTTPS endpoint
- Update
SERVER_URLin.envto your production URL - Configure Plivo webhooks to point to your server
For Inbound Calls
- Start the server:
- Expose your local server using ngrok:
-
Copy the HTTPS URL (e.g.,
https://abc123.ngrok.io) -
Configure your Plivo phone number:
- Go to Plivo dashboard → Phone Numbers
- Select your phone number
- Set Answer URL to:
https://your-ngrok-url.ngrok.io/plivo-inbound - Set Answer Method to:
POST - Optionally set Hangup URL to:
https://your-ngrok-url.ngrok.io/plivo-hangup
Testing
Testing Outbound Calls
- Make sure ngrok is running and
SERVER_URLin.envis updated - Make sure the server is running
- Send a POST request:
- The call should be initiated and connected to the bot
Testing Inbound Calls
- Make sure the server is running
- Make sure ngrok is running and your Plivo number is configured
- Call your Plivo phone number from any phone
- The call should connect to the bot
Troubleshooting
Common Issues
“Module not found” errors- Make sure you activated the virtual environment
- Run
uv pip install -r requirements.txtagain
- Verify your Auth ID and Auth Token in
.env - Check that credentials are correct in Plivo dashboard
- Verify your Daily API key
- Check that your Daily account is active
- For inbound: Verify ngrok is running and URL is correct in Plivo
- For outbound: Verify
SERVER_URLis correct and publicly accessible - Check server logs for incoming webhook requests
- Check bot logs:
tail -f bot_<room_name>.log - Verify all AI service API keys are correct
- Check that bot process started successfully
- Verify Daily room was created successfully
- Check that SIP URI is correct
- Verify bot joined the Daily room (check logs)
Debugging Tips
- Check server logs: Look at the terminal where
server.pyis running - Check bot logs: Look in
bot_<room_name>.logfiles - Check Plivo logs: Go to Plivo dashboard → Logs → Calls
- Check Daily logs: Go to Daily dashboard → Rooms → Select room → View logs
Getting Help
- Daily Support: https://help.daily.co/
- Plivo Support: https://support.plivo.com/
- OpenAI Support: https://help.openai.com/
- Deepgram Support: https://developers.deepgram.com/support
- Cartesia Support: https://cartesia.ai/contact