AutoDialerCampaign Model
The AutoDialerCampaign model represents an outbound dialing campaign with configuration for routing, scheduling, rate limiting, AMD actions, and Caller ID pooling.
Table: auto_dialer_campaigns
Model: App\Models\AutoDialerCampaign
Resource: App\Http\Resources\AutoDialerCampaignResource
Database Schema
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | bigint unsigned | No | auto | Primary key |
organization_id | bigint unsigned | No | - | Foreign key to organizations |
name | varchar(255) | No | - | Campaign name |
description | text | Yes | null | Campaign description |
status | enum | No | draft | draft, active, paused, completed, archived |
auto_start | boolean | No | false | Auto-start when ready |
routing_destination_type | enum | No | - | ai_assistant, ai_load_balancer, hangup |
routing_destination_id | bigint unsigned | Yes | null | Target destination ID |
dial_timeout | smallint unsigned | No | 60 | Seconds to ring before timeout |
destination_connect | enum | No | connected | connected or immediately |
caller_id | varchar(255) | No | - | Default Caller ID, E.164 |
caller_id_strategy | varchar(20) | No | round_robin | Distribution strategy for pool |
caller_id_pool_enabled | boolean | No | false | Whether pool mode is enabled |
max_dial_attempts | tinyint unsigned | No | 1 | Max attempts per destination (API: 1-5) |
concurrent_active_calls | int unsigned | No | 0 | Max concurrent calls (CAC; API: 1-50) |
calls_per_second | tinyint unsigned | No | 1 | Call initiation rate (CPS; API: 1-30) |
days_active | json | No | - | Legacy schedule days |
start_time | tinyint unsigned | Yes | null | Legacy start hour |
end_time | tinyint unsigned | Yes | null | Legacy end hour |
start_date | date | No | - | Campaign start date |
end_date | date | No | - | Campaign end date |
timezone | varchar(255) | No | UTC | Schedule timezone |
schedule | json | Yes | null | Full weekly schedule |
time_limit | mediumint unsigned | No | 600 | Max call duration in seconds (API: 30-14400; omitted or null on create, or null on update, stores 600) |
record_calls | boolean | No | false | Enable recording |
action_voicemail | varchar(255) | Yes | null | AMD action for voicemail (HANGUP or CONTINUE) |
action_human | varchar(255) | Yes | null | AMD action for human |
action_unknown | varchar(255) | Yes | null | AMD action for unknown |
retry_on_voicemail | boolean | No | false | Retry a destination that reached voicemail |
retry_on_busy_no_answer | boolean | No | false | Redial busy / no-answer destinations within max_dial_attempts |
retry_delay_minutes | smallint unsigned | No | 15 | Minutes before the first busy / no-answer retry (1 to 1440); doubles for each further retry, capped at 24 hours |
total_destinations | int unsigned | No | 0 | Total destinations count |
completed_calls | int unsigned | No | 0 | Completed calls count |
failed_calls | int unsigned | No | 0 | Failed calls count |
voicemail_calls | int unsigned | No | 0 | Voicemail calls count |
pending_calls | int unsigned | No | 0 | Pending calls count |
pause_reason | varchar(255) | Yes | null | Reason for pause |
resume_at | timestamp | Yes | null | Scheduled resume time |
started_at | timestamp | Yes | null | When campaign started |
completed_at | timestamp | Yes | null | When campaign completed |
created_at | timestamp | Yes | null | Creation timestamp |
updated_at | timestamp | Yes | null | Last update timestamp |
Indexes
| Index | Columns |
|---|---|
adc_org_status_idx | organization_id, status |
adc_org_auto_start_idx | organization_id, auto_start, status |
adc_dates_idx | start_date, end_date |
auto_dialer_campaigns_routing_destination_id_foreign | routing_destination_id |
organization_id references organizations with ON DELETE CASCADE. routing_destination_id has no foreign key constraint: it points to an AI assistant or an AI load balancer depending on routing_destination_type.
Relationships
Belongs To
campaign.organization() → Organization
campaign.aiAssistant() → AiAssistant (routing_destination_id, when routing to an AI assistant)
campaign.aiLoadBalancer() → AiAssistantLoadBalancer (routing_destination_id, when routing to a load balancer)
Has Many
campaign.lists() → AutoDialerList[] (a campaign can hold several lists)
campaign.destinations() → AutoDialerDestination[] (through its lists)
campaign.callSessions() → AutoDialerCallSession[]
campaign.callerIdStats() → AutoDialerCallerIdStat[]
Belongs To Many
campaign.callerIds() → DidNumber[]
- Pivot: auto_dialer_campaign_caller_ids
- With pivot: weight, with timestamps
Enums
CampaignStatus
| Case | Value |
|---|---|
DRAFT | draft |
ACTIVE | active |
PAUSED | paused |
COMPLETED | completed |
ARCHIVED | archived |
RoutingDestinationType
| Case | Value |
|---|---|
AI_ASSISTANT | ai_assistant |
AI_LOAD_BALANCER | ai_load_balancer |
HANGUP | hangup |
CallerIdStrategy
| Case | Value |
|---|---|
ROUND_ROBIN | round_robin |
RANDOM | random |
LEAST_RECENTLY_USED | least_recently_used |
DestinationConnect
| Value | Description |
|---|---|
connected | Connect when call answered |
immediately | Connect immediately |
Caller ID Pooling
Enable Pool Mode
$campaign->update([
'caller_id_pool_enabled' => true,
'caller_id_strategy' => 'round_robin', // or 'random', 'least_recently_used'
]);
Assign Caller IDs
$syncData = [
$didId1 => ['weight' => 1],
$didId2 => ['weight' => 1],
];
$campaign->callerIds()->sync($syncData);
Methods
Scopes
AutoDialerCampaign::forOrganization($orgId)
AutoDialerCampaign::active()
AutoDialerCampaign::paused()
AutoDialerCampaign::draft()
AutoDialerCampaign::runnable() // Active, with start_date/end_date within one day of today (coarse pre-filter; isRunnable() does the exact, timezone-aware check)
Business Logic
$campaign->isRunnable(): bool
$campaign->getProgressPercentage(): int
$campaign->getApiIntervalMilliseconds(): float
$campaign->hasValidCac(): bool
$campaign->hasValidCps(): bool
$campaign->hasList(): bool // at least one list assigned
$campaign->canStart(): bool
$campaign->canPause(): bool
$campaign->canAcceptList(): bool
$campaign->listAssignmentRefusal(): ?string // why a list cannot be added now (status, or running), or null
$campaign->getPendingCount(): int // destinations with status pending
$campaign->getRoutingDestinationLabel(): string
$campaign->clearRedisKeys(): void // deletes dialer:cac:{id}:active and campaign:{id}:caller_id_index on the dialer Redis
isRunnable() evaluates the current time in the campaign's timezone and checks the date range and the schedule time ranges for today. getApiIntervalMilliseconds() returns 1000 / calls_per_second. hasValidCac() and hasValidCps() check the MIN_CAC/MAX_CAC (1-50) and MIN_CPS/MAX_CPS (1-30) constants.