Skip to main content

A Django package for call center functionality using Twilio

Project description

django-twilio-call

PyPI version Python Support Django Support License: MIT Tests Coverage Documentation

django-twilio-call is an enterprise-grade Django package for building sophisticated call center applications using Twilio's powerful communication APIs. Build production-ready call centers with features like IVR, call routing, recording, real-time monitoring, and comprehensive analytics.

โœจ Features

Core Call Center Functionality

  • ๐Ÿ“ž Inbound/Outbound Calls - Handle both incoming and outgoing calls with ease
  • ๐Ÿ”€ Intelligent Call Routing - Route calls based on skills, availability, and priority
  • ๐Ÿ‘ฅ Agent Management - Complete agent system with status tracking and queue assignment
  • ๐Ÿ“Š Queue Management - Sophisticated queue system with priority and overflow handling
  • ๐ŸŽ™๏ธ Call Recording - Record calls with compliance features and transcription support
  • ๐Ÿ”Š IVR System - Build complex Interactive Voice Response flows
  • ๐ŸŽฏ Real-time Monitoring - Track call center metrics and agent performance in real-time

Enterprise Features

  • ๐Ÿ” JWT Authentication - Secure API access with JSON Web Tokens
  • โšก Rate Limiting - Protect your APIs from abuse with configurable rate limits
  • ๐Ÿ›ก๏ธ RBAC - Role-Based Access Control for agents and supervisors
  • ๐Ÿ“ˆ Analytics & Reporting - Comprehensive call analytics and performance metrics
  • ๐Ÿ”„ WebSocket Support - Real-time updates for live dashboards
  • ๐Ÿ“ก Webhook Handling - Secure webhook processing with signature validation
  • โš™๏ธ Celery Integration - Asynchronous task processing for scalability

Production Ready

  • ๐Ÿณ Docker Support - Complete Docker configuration for easy deployment
  • โ˜ธ๏ธ Kubernetes Ready - Kubernetes manifests for cloud-native deployment
  • ๐Ÿ“Š Monitoring - Prometheus metrics and health check endpoints
  • ๐Ÿš€ Performance - Redis caching and database optimization
  • ๐Ÿ”’ Security - Enterprise-grade security with input validation and encryption
  • ๐Ÿ“ Documentation - Comprehensive documentation with examples

๐Ÿš€ Quick Start

Installation

pip install django-twilio-call

Basic Setup

  1. Add to INSTALLED_APPS
INSTALLED_APPS = [
    ...
    'django_twilio_call',
    'rest_framework',
    'corsheaders',
    ...
]
  1. Configure Twilio Settings
# settings.py
TWILIO_ACCOUNT_SID = 'your_account_sid'
TWILIO_AUTH_TOKEN = 'your_auth_token'
TWILIO_PHONE_NUMBER = '+1234567890'
TWILIO_WEBHOOK_URL = 'https://your-domain.com/webhooks/twilio/'
  1. Run Migrations
python manage.py migrate django_twilio_call
  1. Include URLs
# urls.py
urlpatterns = [
    ...
    path('api/call-center/', include('django_twilio_call.urls')),
    ...
]

๐Ÿ“– Usage Examples

Making an Outbound Call

from django_twilio_call import call_service

# Make a call
call = call_service.create_call(
    to_number='+1987654321',
    from_number='+1234567890',
    agent_id=agent.id
)

Handling Inbound Calls

from django_twilio_call.webhooks import VoiceWebhookView

class InboundCallHandler(VoiceWebhookView):
    def handle_incoming_call(self, call_data):
        # Route to available agent
        agent = self.find_available_agent()
        if agent:
            return self.route_to_agent(call, agent)
        else:
            return self.route_to_queue(call)

Managing Agents

from django_twilio_call import agent_service

# Update agent status
agent_service.update_status(agent_id, 'available')

# Assign agent to queue
agent_service.assign_to_queue(agent_id, queue_id)

# Get agent statistics
stats = agent_service.get_statistics(agent_id)

Queue Management

from django_twilio_call import queue_service

# Create a queue
queue = queue_service.create_queue(
    name='Support Queue',
    max_size=50,
    timeout_seconds=300
)

# Get queue statistics
stats = queue_service.get_queue_statistics(queue_id)

๐Ÿ”ง Advanced Configuration

Celery Setup

# settings.py
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'

# Enable async task processing
DJANGO_TWILIO_ASYNC_TASKS = True

JWT Authentication

# settings.py
SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=15),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
    'ROTATE_REFRESH_TOKENS': True,
}

Rate Limiting

# settings.py
REST_FRAMEWORK = {
    'DEFAULT_THROTTLE_RATES': {
        'burst': '60/min',
        'sustained': '1000/hour',
        'call_api': '100/hour',
    }
}

๐Ÿณ Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

# Scale workers
docker-compose scale celery_worker=3

๐Ÿ“Š Monitoring

The package includes built-in monitoring endpoints:

  • /health/ - Basic health check
  • /health/detailed/ - Detailed component status
  • /metrics/ - Prometheus metrics

๐Ÿงช Testing

# Run tests
pytest

# Run with coverage
pytest --cov=django_twilio_call

# Run with tox for multiple environments
tox

๐Ÿ“š Documentation

Full documentation is available at https://django-twilio-call.readthedocs.io/

Key Documentation Sections:

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

# Clone the repository
git clone https://github.com/hmesfin/django-twilio-call.git

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Run linters
ruff check .

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

๐Ÿšฆ Project Status

This project is actively maintained and ready for production use. We follow semantic versioning and maintain backward compatibility within major versions.


Made with โค๏ธ by Gojjo Tech

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_twilio_call-0.1.2.tar.gz (229.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_twilio_call-0.1.2-py2.py3-none-any.whl (269.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_twilio_call-0.1.2.tar.gz.

File metadata

  • Download URL: django_twilio_call-0.1.2.tar.gz
  • Upload date:
  • Size: 229.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for django_twilio_call-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9dc043baf137b3b89032cf5f64d099a297087da626436543ce6dc28e306fbaf0
MD5 a675ff2af8a95edb49fd220f90b1ffa9
BLAKE2b-256 69194c04b4856a3bd24b3dbe6a6b8cd0cc53b061a9775a8263e0aa241a174c22

See more details on using hashes here.

File details

Details for the file django_twilio_call-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_twilio_call-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c3ffa68bff5795fef5459e7461231ec03d2fdbf0732ba0dab3adb2dcf839204c
MD5 8ba6ff15eb4b08a3ffa74ef912ac720a
BLAKE2b-256 65032f718d6b9be180885f37ebb07f13af3be6bf52aed767640ed6e86c4c01c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page