A Python-based webhook server for receiving and processing Agora video calling notifications. This server provides real-time analytics and monitoring for your Agora applications.
- Webhook Reception: Receives Agora webhooks via HTTPS POST requests with route-based App ID handling
- Real-time Processing: Processes webhook events and calculates usage metrics
- Web Dashboard: Beautiful web interface for viewing channel analytics and user statistics
- Security: Simplified webhook processing without signature verification
- Database Storage: SQLite database for storing webhook events and calculated metrics
- Monitoring: Built-in health checks and monitoring scripts
- Production Ready: Systemd service, nginx reverse proxy, SSL support
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Agora Cloud │───▶│ Webhook Server │───▶│ SQLite DB │
│ │ │ (FastAPI) │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Web Dashboard │
│ (HTML/JS) │
└──────────────────┘
git clone <your-repo-url>
cd AgoraWebhookspython3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtCreate your environment configuration:
cp env.example .env
# Edit .env with your settingspython main.pyThe server will start on http://localhost:8000
Run the deployment script on your Ubuntu 24.04 server:
./deploy.sh| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
SQLite database path | sqlite:///./agora_webhooks.db |
HOST |
Server host | 0.0.0.0 |
PORT |
Server port | 443 |
SSL_CERT_PATH |
SSL certificate path | None |
SSL_KEY_PATH |
SSL private key path | None |
LOG_LEVEL |
Logging level | INFO |
LOG_FILE |
Log file path | agora_webhooks.log |
- Log in to Agora Console
- Navigate to your project
- Go to All Features → Notifications
- Configure:
- Event: Select events you want to monitor (e.g., User joined/left channel)
- Receiving Server URL Endpoint:
https://your-domain.com/{app_id}/webhooks - Whitelist: Add your server's IP addresses
POST /{app_id}/webhooks
Receives Agora webhook notifications for the specified App ID.
Headers:
Content-Type:application/json
Example:
curl -X POST https://your-domain.com/your-app-id/webhooks \
-H "Content-Type: application/json" \
-d '{
"noticeId": "12345",
"productId": 1,
"eventType": 1,
"payload": {
"clientSeq": 67890,
"uid": 123,
"channelName": "test_channel",
"ts": 1560496834
}
}'GET /api/channels/{app_id}- Get list of channels for an App IDGET /api/channel/{app_id}/{channel_name}- Get detailed channel informationGET /api/user/{app_id}/{uid}- Get user metricsGET /health- Health check endpoint
GET /- Main dashboard interface
- webhook_events - Raw webhook events from Agora
- channel_sessions - Calculated user sessions with join/leave times
- channel_metrics - Aggregated metrics per channel per day
- user_metrics - Aggregated metrics per user per channel per day
sudo systemctl status agora-webhooks# Service logs
sudo journalctl -u agora-webhooks -f
# Application logs
tail -f /var/log/agora-webhooks.log
# Monitor script logs
tail -f /var/log/agora-webhooks-monitor.logcurl https://your-domain.com/health- HTTPS Only: Production deployment uses SSL/TLS encryption
- Security Headers: Nginx configured with security headers
- Firewall: UFW configured to allow only necessary ports
- No Signature Verification: Webhooks are accepted without signature validation for simplified operation
-
Service won't start
sudo systemctl status agora-webhooks sudo journalctl -u agora-webhooks -n 50
-
Webhook processing fails
- Check webhook payload format matches expected structure
- Verify App ID in URL path is valid
-
Database issues
# Check database file permissions ls -la agora_webhooks.db # Reset database (WARNING: deletes all data) rm agora_webhooks.db python -c "from database import create_tables; create_tables()"
-
SSL certificate issues
# Renew Let's Encrypt certificate sudo certbot renew sudo systemctl reload nginx
AgoraWebhooks/
├── main.py # FastAPI application
├── config.py # Configuration management
├── database.py # Database models and setup
├── models.py # Pydantic models
├── webhook_processor.py # Webhook processing logic
├── templates/ # HTML templates
│ └── index.html # Web dashboard
├── requirements.txt # Python dependencies
├── deploy.sh # Deployment script
└── README.md # This file
- New Webhook Events: Update
webhook_processor.pyto handle new event types - New Metrics: Add new tables in
database.pyand update processing logic - New API Endpoints: Add routes in
main.py - UI Changes: Modify
templates/index.html
This project is licensed under the MIT License.
For issues and questions:
- Check the troubleshooting section
- Review the logs
- Create an issue in the repository