Crate rvoip_call_engine

Source
Expand description

§RVOIP Call Engine

A comprehensive call center orchestration engine built on top of the RVOIP SIP stack. This crate provides enterprise-grade call center functionality including agent management, call queuing, intelligent routing, and real-time monitoring.

§Overview

The Call Engine is the heart of a modern call center system, providing:

  • Call Orchestration: Central coordination of agent-customer calls with SIP bridge management
  • Agent Management: Registration, availability tracking, skill-based routing, and performance monitoring
  • Call Queuing: Priority-based queues with overflow policies and wait time management
  • Intelligent Routing: Business rules engine with skill matching and load balancing
  • Real-time Monitoring: Live dashboards, quality metrics, and supervisor tools
  • Database Integration: Persistent storage with SQLite (Limbo) for scalability

§Architecture

The call center is built on a modular architecture:

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Client API    │    │  Supervisor API │    │    Admin API    │
└─────────────────┘    └─────────────────┘    └─────────────────┘
          │                       │                       │
          └───────────────────────┼───────────────────────┘
                                  │
                     ┌─────────────────┐
                     │ CallCenterEngine │
                     └─────────────────┘
                                  │
          ┌───────────────────────┼───────────────────────┐
          │                       │                       │
 ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
 │  Agent Registry │    │  Queue Manager  │    │ Routing Engine  │
 └─────────────────┘    └─────────────────┘    └─────────────────┘
          │                       │                       │
          └───────────────────────┼───────────────────────┘
                                  │
                       ┌─────────────────┐
                       │ Session Manager │ (rvoip-session-core)
                       └─────────────────┘

§Quick Start

§Basic Call Center Setup

use rvoip_call_engine::prelude::*;
 
// Create configuration with sensible defaults
let config = CallCenterConfig::default();
 
// Create call center with in-memory database for this example
let call_center = CallCenterEngine::new(config, None).await?;
 
println!("Call center engine created successfully!");

§Agent Registration

use rvoip_call_engine::prelude::*;
 
// Define an agent with skills and capabilities
let agent = Agent {
    id: "agent-001".to_string(),
    sip_uri: "sip:alice@call-center.local".to_string(),
    display_name: "Alice Johnson".to_string(),
    skills: vec!["english".to_string(), "sales".to_string(), "tier1".to_string()],
    max_concurrent_calls: 2,
    status: AgentStatus::Available,
    department: Some("sales".to_string()),
    extension: Some("1001".to_string()),
};
 
// Register the agent (this creates a SIP session)
let session_id = call_center.register_agent(&agent).await?;
println!("Agent {} registered with session ID: {}", agent.display_name, session_id);

§Advanced Routing Configuration

use rvoip_call_engine::prelude::*;
 
let mut config = CallCenterConfig::default();
 
// Configure skill-based routing
config.routing.default_strategy = RoutingStrategy::SkillBased;
config.routing.enable_load_balancing = true;
config.routing.load_balance_strategy = LoadBalanceStrategy::LeastBusy;
 
// Configure queue settings
config.queues.default_max_wait_time = 300; // 5 minutes max wait
config.queues.max_queue_size = 50;
config.queues.enable_priorities = true;
 
// Configure agent settings
config.agents.enable_skill_based_routing = true;
config.agents.default_skills = vec!["general".to_string(), "english".to_string()];
 
let call_center = CallCenterEngine::new(config, None).await?;

§Monitoring and Statistics

use rvoip_call_engine::prelude::*;
 
// Get real-time statistics
let stats = call_center.get_stats().await;
println!("Call Center Status:");
println!("  Active calls: {}", stats.active_calls);
println!("  Available agents: {}", stats.available_agents);
println!("  Queued calls: {}", stats.queued_calls);
println!("  Total calls handled: {}", stats.total_calls_handled);
 
// Get detailed routing statistics
println!("Routing Performance:");
println!("  Direct routes: {}", stats.routing_stats.calls_routed_directly);
println!("  Queued calls: {}", stats.routing_stats.calls_queued);
println!("  Rejected calls: {}", stats.routing_stats.calls_rejected);

§Key Modules

  • orchestrator: Core call center coordination and bridge management
  • agent: Agent registration, status tracking, and skill-based routing
  • queue: Call queuing with priorities and overflow handling
  • routing: Intelligent call routing engine with business rules
  • monitoring: Real-time monitoring, metrics collection, and analytics
  • api: Public APIs for client applications, supervisors, and administrators
  • integration: Session-core integration adapters and handlers
  • database: Persistent storage with Limbo SQLite database
  • config: Configuration management and validation
  • error: Comprehensive error handling and result types

§Integration with RVOIP Stack

This crate integrates seamlessly with other RVOIP components:

  • rvoip-session-core: SIP session management and call handling
  • rvoip-sip-core: Low-level SIP protocol handling
  • rvoip-media-core: Audio processing and codec management
  • rvoip-client-core: Client-side integration for softphones

§Network Configuration

The call engine properly respects and propagates configured bind addresses:

use rvoip_call_engine::prelude::*;
 
// Configure specific IP addresses for your deployment
let mut config = CallCenterConfig::default();
config.general.local_signaling_addr = "127.0.0.1:5060".parse().unwrap();  // Use localhost for test
config.general.local_media_addr = "127.0.0.1:20000".parse().unwrap();     // Same IP for media
 
// The engine ensures these addresses propagate to all layers
let engine = CallCenterEngine::new(config, None).await?;

Key points:

  • Configured IPs propagate through session-core to dialog-core and transport
  • No more hardcoded 0.0.0.0 addresses - your specific IP is used everywhere
  • Media port range starts from the configured local_media_addr port

For automatic media port allocation, the engine uses the port from local_media_addr as the base and allocates a range from there (typically +1000 ports).

§Production Deployment

For production deployments, consider:

  • Database: Use a dedicated database file with regular backups
  • Monitoring: Enable real-time monitoring and quality alerts
  • Security: Configure proper authentication and authorization
  • Scaling: Monitor agent and call limits, scale horizontally as needed
  • Network: Ensure proper SIP and RTP port configuration with specific bind addresses

§Examples

See the examples/ directory for complete working examples:

  • e2e_test/: End-to-end call center testing setup
  • Basic call center server implementation
  • Agent client simulation
  • Load testing scenarios

Re-exports§

pub use error::CallCenterError;
pub use error::Result;
pub use config::CallCenterConfig;
pub use orchestrator::core::CallCenterEngine;
pub use api::CallCenterClient;
pub use api::SupervisorApi;
pub use api::AdminApi;
pub use server::CallCenterServer;
pub use server::CallCenterServerBuilder;

Modules§

agent
Agent management module for the call center
api
Public API module for call center applications
config
database
Async Database Management Module (sqlx + SQLite)
error
integration
Session-core integration module
monitoring
Call Monitoring and Analytics Module
orchestrator
Call Center Orchestration Module
prelude
Prelude module for convenient imports
queue
Call Queue Management Module
routing
Call Routing Engine Module
server
Call Center Server Manager

Structs§

CallCenterStats
Call center statistics and performance metrics