Skip to content

Repository files navigation

ElevenLabs DTMF Webhook for IVR Navigation

This webhook server enables ElevenLabs voice agents to send DTMF tones (phone keypad presses) to navigate IVR systems when making outbound calls via Twilio.

Features

  • ✅ Send DTMF tones to active Twilio calls
  • ✅ Track active call sessions
  • ✅ Receive Twilio call status webhooks
  • ✅ Health check endpoint
  • ✅ Comprehensive logging

Setup

1. Install Dependencies

pip install -r requirements.txt

2. Configure Environment Variables

Copy the example environment file:

cp .env.example .env

Edit .env and add your Twilio credentials:

TWILIO_ACCOUNT_SID=your_actual_account_sid
TWILIO_AUTH_TOKEN=your_actual_auth_token

Get these from: https://console.twilio.com

3. Run Locally

python app.py

Server will start on http://localhost:8080

4. Test Health Check

curl http://localhost:8080/health

API Endpoints

POST /send-dtmf

Send DTMF tones to an active call.

Request:

{
  "digits": "1",
  "call_sid": "CAxxxxxxxxxxxxx"
}

Response:

{
  "success": true,
  "message": "Sent DTMF: 1",
  "call_sid": "CAxxxxxxxxxxxxx",
  "digits": "1",
  "timestamp": "2025-11-12T18:30:00"
}

POST /webhook/call-status

Twilio status callback endpoint. Configure in Twilio Console.

GET /health

Health check endpoint.

GET /active-calls

List currently active calls.

Deployment

Option 1: Deploy to Railway

  1. Install Railway CLI: https://docs.railway.app/develop/cli
  2. Run:
railway login
railway init
railway up

Option 2: Deploy to Render

  1. Create account at https://render.com
  2. Connect your GitHub repo
  3. Add environment variables in Render dashboard
  4. Deploy

Option 3: Deploy to Fly.io

  1. Install flyctl: https://fly.io/docs/hands-on/install-flyctl/
  2. Run:
fly launch
fly secrets set TWILIO_ACCOUNT_SID=xxx TWILIO_AUTH_TOKEN=xxx
fly deploy

Configure Twilio

  1. Go to Twilio Console → Phone Numbers
  2. Select your ElevenLabs phone number
  3. Under "Voice Configuration":
    • Status Callback URL: https://your-webhook-url.com/webhook/call-status
    • Check: Initiated, Ringing, Answered, Completed
  4. Save

Configure ElevenLabs

  1. In your ElevenLabs agent → Tools → send_dtmf
  2. Edit the webhook URL to: https://your-webhook-url.com/send-dtmf
  3. Save

Testing

Test DTMF sending:

curl -X POST http://localhost:8080/send-dtmf \
  -H "Content-Type: application/json" \
  -d '{"digits": "1", "call_sid": "CAxxxxx"}'

Troubleshooting

Issue: "Twilio client not initialized"

  • Solution: Check that TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN are set correctly

Issue: "No active call found"

  • Solution: Ensure Twilio Status Callback is configured correctly
  • Or pass call_sid explicitly in the request

Issue: DTMF not being sent

  • Solution: Verify the call_sid is correct and the call is still active

Logs

All requests and errors are logged to console with timestamps.

Monitor logs:

tail -f app.log  # if using file logging

Security Notes

  • Always use HTTPS in production
  • Keep your Twilio credentials secure
  • Consider adding authentication to webhook endpoints
  • Use environment variables, never hardcode credentials

License

MIT

About

Webhook for Eleven labs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages