Shared behaviour
Settle, retry, wrap, pause, decline, redial, missed activities.
These rules are the same in Progressive and Predictive. Hangup writes master + sales_dialer_call_attempts (snapshot of master data_id at settle, for outgoing / incoming / redial). Only Not Connected increments call_count and uses retry_pattern + max_tries. Abandoned keeps an existing next_retry_at, or schedules retry_seconds when null — it is not on the NC retry cycle.
Hangup map
| AMI / condition | Stored status |
|---|---|
DialStatus = ANSWER (talked) | Received |
| Customer left on hold / connecting | Abandoned |
Cancel, DONTCALL, INVALIDARGS, causes 1, 21, 22, 27–29 | Rejected |
NOANSWER, BUSY, CONGESTION, CHANUNAVAIL, causes 16–20 | Not Connected |
Settle only updates rows still Calling. Agent, duration, hold seconds, and data_id are on the attempt row, not master. Attempt dial_status is this call’s outcome; previous_dial_status is master at claim.
System dispositions
Hangup settle stamps work_status / sub_disposition / disposition_source = system on sales_dialer_call_attempts for system outcomes. Received stays blank at hangup — the agent must CRM dispose or schedule a callback. If they socket-redial that talk first, the blank Received attempt is stamped then.
| Attempt status | Work status | Sub disposition | Remarks |
|---|---|---|---|
Not Connected + BUSY (or cause 17) | Call Disconnected | Busy | — |
Not Connected + NOANSWER / other NC | Call Disconnected | Ringing no response | — |
Not Connected + CHANUNAVAIL / CONGESTION | Call Disconnected | Switch Off | — |
| Abandoned | Call Disconnected | Customer Disconnected | — |
| Rejected | Call Disconnected | Invalid Number | — |
| Received (at hangup) | — | — | — |
| Received (blank) when socket redial reopens it | Call Disconnected | Redial | Agent redialed after connected call before CRM disposition |
Talked → dropped → redial: after a bridged Received, missed activity still requires a CRM callback or disposition. When the agent socket-redials first, the prior blank Received attempt is stamped Call Disconnected / Redial with that system remark (CRM labels already on that attempt are left alone). Redial NC attempts are stamped as above (call_type = redial) without auto-sticky and without bumping call_count. For a timed follow-up, schedule Call Disconnected or a sticky callback.
CRM labels on attempts: when a pending callback or disposition is applied, its work_status / sub_disposition / remarks are copied onto the matching attempt (disposition_source = crm, prefer call_id, else latest for the OLI).
CRM history: read sales_dialer_call_attempts.work_status, sub_disposition, and remarks (by oli_id / call_id). Those columns are not on master.
Retry
| Not Connected | Abandoned | |
|---|---|---|
| Wait | First NC: 10 minutes; later open-bucket NCs: retry_seconds (currently 3600) same day; bucket complete → next work_start | Keep existing next_retry_at, else retry_seconds (work-hours clamped). No pattern / max_tries |
| Pattern | retry_pattern buckets (currently [4,4,3,2,1,1,1,1,1,1,1]); leftover carries to the next working day | Ignored |
max_tries | Disposes when call_count hits the cap (currently 20) | Ignored |
call_count | Increments on this settle | Unchanged |
| Auto-claim | When next_retry_at is null or due | Only when next_retry_at is set and due |
Dispose exclusion uses only this module’s sales_dialer_config (sales-dialer). Live in-house row (seed defaults differ: max_tries=8, pattern [4,2,1], work_end=18:30, Mon–Sat): retry_pattern = [4,4,3,2,1,1,1,1,1,1,1], retry_seconds = 3600, max_tries = 20, work_days = [1,2,3,4,5,6,7], window 09:30–21:30, outbound_obey_work_hours = 0.
Claim order
Same SELECT_CLAIM for progressive, predictive pool, and sticky progressive place (FOR UPDATE SKIP LOCKED, then Calling + reserved). Auto-claim needs skill and priority_ids on the same agent (empty allowlist = all).
Untouched Fresh Assign (agent-first, quota-gated): a lead is untouched fresh when priority_id is Fresh Assign (2), it has no Received or Not Connected row in sales_dialer_call_attempts, and it is not yet in sales_dialer_lead_allotments. These are never claimed customer-first. Each idle ready agent claims them one at a time and rings agent-first progressive, even when the floor is Predictive. An agent at their fresh_lead_limit gets none. Callbacks, Not Connected retries, sticky, and redial still claim normally. See Fresh lead allotment.
Claim order (first → last):
Fresh Assign Pending → fresh Callback (due) → Fresh Assign Abandoned → Callback Abandoned → Not Connected Fresh Assign → Not Connected Callback
A future callback_scheduled_at is skipped until due. Final Disposal is never claimed. A Callback Schedule lead pushed with no time can sit as Pending (rare); normal callbacks are dial_status = Callback when due.
Anything except Not Connected.
priority_no ascending: a fresh Fresh Assign (Pending, 1) before a fresh Callback (dial_status = Callback, 2). Within one fresh priority: Callback → Pending → Abandoned, then never-attempted, oldest last_attempt_at, LIFO push_date / id.A due Callback is claimed before any Not Connected. Inside Not Connected, Fresh Assign drains before Callback Schedule. A Not Connected row can be either priority.
Lowest
call_count, then latest next_retry_at (LIFO), then the same age / push tail.Sticky: pin filters only decide who may claim. On the progressive floor a fresh Fresh Assign still drains before that agent’s fresh Callback, including a sticky due callback, and Not Connected stays behind those fresh rows. Predictive sticky place uses stickyOnly (only that employee’s pins), so a pinned due callback can still be dialed while fresh Fresh Assign remains in the pool. Among that agent’s due sticky NC rows, the NC order applies. Active sticky leads are excluded from the predictive pool. Details: Callback stickiness.
Claim only reserves the row (Calling, isReserved = 1, reserved_at). first_attempt_at / last_attempt_at are written right before a real outbound originate, or on an inbound claim. A claim released without dialing restores the previous status and waits RELEASE_RETRY_MS (default 60s; invalid numbers keep retry_seconds). Predictive claims only leads that one idle agent can take (skill and priority on the same agent). Socket redial bypasses this queue. /api/health reports metrics.released, metrics.releasedNoAgent, leads.phantomAttempts (target 0) and leads.uncoveredLeads.
Wrap and working hours
buffer_time is per-agent wrap after a connected call. Hangup starts wrap as usual; for outgoing/redial the bridged call also opens a missed-activity row. When disposition or callback clears that agent's last uncleared missed row and the desk is Ready (panel active, SIP idle, not on a call), remaining wrap is cleared immediately so auto-dial can resume — hangup alone never clears wrap. Inbound-only hangups keep the full buffer_time. A miss with no lead retries claim every 10 seconds. Originate is refused when isMaintainance = 1. Auto-dial also needs an idle ready agent whose skills match the lead form_type and whose priority_ids allow the lead’s priority_id.
sales_dialer_config.outbound_obey_work_hours (default 0) controls whether outbound auto-dial (progressive and predictive) follows work_start–work_end on work_days:
| Flag | Outbound auto-dial | Inbound | Socket redial | Retry scheduling |
|---|---|---|---|---|
0 (default) | Any time a ready, matching agent exists | After-hours rules still apply | Never gated by hours | next_retry_at still clamped to the window |
1 | Only inside the work window (old behavior) | After-hours rules still apply | Never gated by hours | next_retry_at still clamped to the window |
Because retry scheduling stays clamped, after hours only leads whose next_retry_at is already due (or null) are claimed. A Not Connected at 18:45 still waits for the next work_start. Turn the old behavior back on with UPDATE sales_dialer_config SET outbound_obey_work_hours = 1 WHERE module_id = 'sales-dialer';
Pause, Logout, leave, and attendance
| Action | Socket | panel_status | Pause clock | Attendance session |
|---|---|---|---|---|
| Active / Ready | ready | active | Cleared; closes open pause row | Opens a new row, or reopens today’s Logout row (keeps original logged_in_at) |
| Pause (lunch, bio, …) | pause + reason | pause | Starts | Stays open |
| Logout | pause logout | yet_to_login | Cleared | Closes (logout_reason = logout) |
| Leave / disconnect | auto after last tab + 3s | pause (left) unless already yet_to_login | May open | Stays open (leave does not end attendance) |
Agent pause requires a picker reason from public GET /api/pause-reasons. Invalid → server_error invalid_pause_reason. other needs a short note. On-demand OLI uses socket redial with ondemand: true — not a pause-reason code. Dashboard Work column clocks from paused_at while truly paused; Logout / yet_to_login show “yet to login” with no clock.
Daily day reset at PAUSE_DAY_RESET_AT (default 00:00 IST) closes open pauses started before today, sets those desks to yet_to_login, stamps still-open sales_dialer_agent_sessions with day_reset (Logout rows are left alone), closes open sales_dialer_agent_readiness_gaps, and replaces the missed dials snapshot in sales_dialer_undialed_day for the closed calendar day. A lead is missed when it was due that day and had no attempt at or after due_at. Reasons: on_call, no_matching_agent, not_reached. This is not the live Undialed claim pool. Same-day pauses stay open. Dial window work_start–work_end is separate. Kill switch: PAUSE_DAY_RESET_ENABLED=0. Reports: GET /api/agent-sessions, GET /api/agent-readiness-gaps.
Ready-time gaps: while Work is Ready and an attendance session is open, intervals in sales_dialer_agent_readiness_gaps record AMI unavailable and/or Panel inactive (5s debounce). Observer-only — does not change dialing. Not the same as microsip_alert (Panel active + AMI down toast).
SIP deny on a live predictive/inbound hold records sales_dialer_agent_declines and blocks that extension for the same caller for decline_cooldown_seconds (default 30). The customer stays on hold.
Maintenance
sales_dialer_config.isMaintainance (column spelling as stored) is the floor switch. 0 / null is fail-open (calls run). 1 stops new predictive/progressive originates, socket redial, and inbound park/offer (PSTN is left to FreePBX). Live talks are not hung. Dashboard and agent show a MAINTENANCE banner; the CRM sales-dialer page shows a "Maintenance mode" banner. Reloaded with the rest of config every 30 seconds.
Placement modes
dialer_type chooses the floor engine for auto-dial only. Several paths always ring the agent first (progressive place), even when the floor is Predictive:
| Path | When | How the phone rings |
|---|---|---|
| Progressive auto-dial | Floor is Progressive | Agent channel first, then customer |
| Predictive auto-dial | Floor is Predictive | Customer Local first, then bridge a skilled idle agent |
| Sticky place | Active sticky pin due for that agent | Always agent-first progressive (even on Predictive) |
| Socket redial / On demand | Agent emits redial | Always agent-first progressive (even on Predictive) |
| Untouched Fresh Assign | Fresh Assign, no Received / NC attempt, not yet allotted, agent under fresh_lead_limit | Always agent-first progressive (even on Predictive). Never customer-first |
Do not confuse floor badge status.call_type (Progressive / Predictive) with attempt call_type on dialer / call_connected / sales_dialer_call_attempts (outgoing / incoming / redial).
Fresh lead allotment
Each agent can have a daily cap on untouched fresh leads, stored on sales_dialer_employee.fresh_lead_limit (migration 059_fresh_lead_allotment.sql).
fresh_lead_limit | Mode | Untouched Fresh Assign leads |
|---|---|---|
NULL (default) | unlimited | No limit. Existing employees keep today's behaviour |
0 | blocked | Never claimed by this agent. Callbacks, NC retries, sticky, inbound, and redial still flow |
N > 0 | limited | At most N allotments per IST calendar day. At the cap, no more untouched fresh leads until midnight IST |
What counts. A row is written to sales_dialer_lead_allotments (UNIQUE (oli_id)) only on the first both-way connect: the customer answered and was bridged to the agent (the first Received talk). Ringing the agent's SIP phone does not allot. The agent answering and the customer not answering does not allot either, and the lead settles Not Connected as usual.
Reset. The count is per IST calendar day (allotted_date = DATE(NOW()) on the DB_TIMEZONE session clock, +05:30), so the cap resets automatically at midnight IST.
Quota only. An allotment does not pin the lead to that agent. Callbacks and NC retries stay in the shared pool.
Unaccepted ring. If the agent never picks up the SIP ring, the lead goes back to its previous status with no attempt row, no allotment, and no Not Connected. The same agent waits decline_cooldown_seconds before that lead is offered to them again. Other ready agents can take it immediately.
Retries. Not Connected retries stay in the shared Predictive pool, so on a Predictive floor they use originateCustomer like any other NC.
Redial / On demand
Socket redial { oli_id } from a joined agent (CRM sales-dialer page, /agent.html, or any client). Same event for after-call redial and On demand (ondemand: true).
- Claims that exact OLI for this employee (skill must match; priority allowlist is not checked).
- Skips wrap (
buffer_time), the auto-claim queue, and predictive slot / ratio pacing. - Places the call agent-first progressive — including when
dialer_typeis Predictive. Same path as sticky progressive place. Predictive customer-first pacing never runs this leg. - Stores attempt
call_type = redial. Livedialer/call_connectedshow Redial in the Type slot. Floor badge stays Progressive / Predictive.
| Gate | Behavior |
|---|---|
| Maintenance | error: maintenance |
| Missed-activity block | Only that agent’s own missed OLIs; else error: missed_activity |
ondemand: true | Allowed while Paused if SIP idle; on success hub sets Ready |
Without ondemand | Agent must already be Ready |
| Work hours | Never gated by outbound_obey_work_hours |
| Reopen | Any active master row, including Received / Rejected / Disposed |
| NC on redial | Does not increment master call_count |
Payload and error codes: Socket guide → redial. Sticky also uses agent-first progressive: Callback stickiness.
Missed activities
Every bridged outgoing or redial call (customer and agent both answered) opens a row in sales_dialer_missed_activities for that agent and OLI. Incoming calls are not tracked. Settle stamps ended_at and due_at = ended_at + MISSED_ACTIVITY_GRACE_MINUTES (default 10).
A 15 second refresh collects uncleared rows past due_at. An agent with any such row is outbound blocked:
- Predictive and progressive stop offering or originating outbound to that desk (
missed_activity). - Socket
redial(including on-demand) fails witherror: missed_activity, unless the OLI is one of that agent's own missed leads, so they can call the customer back. - Inbound offers are unaffected. Pause / Active work as before.
The block clears when the CRM stores a pending callback or pending disposition for the OLI. That clears every open row for the OLI, whoever submits, and the agent is re-evaluated immediately. Rows that never got a hangup (crash or lost AMI event) are closed by the stale sweep after 120 minutes when the lead is not on a call, then follow the same grace rule.
| Where | What the agent / supervisor sees |
|---|---|
Socket dialer | outbound_blocked and missed_activities: [{ oli_id, due_at }] (overdue only, max 20) |
| Agent page | Banner with the OLIs; status line "Outbound disabled — complete missed activities" |
| CRM sales-dialer page | "Outbound paused" banner (on demand disabled) and a compact Missed activities panel beside the lead card: name, due countdown / Overdue, OLI, with Call (redial) and Details (load the card to dispose or schedule). Data from GET /api/missed-activities?extension= |
| Dashboard | Dialer column shows Outbound blocked (hover lists OLIs). Outgoing blocked panel under Waiting idle lists blocked agents with time since the oldest missed lead went overdue. Blocked agents are not counted as waiting idle |
Config: MISSED_ACTIVITY_ENABLED=0 turns tracking and blocking off; MISSED_ACTIVITY_GRACE_MINUTES sets the grace window. Table from migration 042_missed_activities.sql.
Priorities
Only three rows in sales_dialer_priority. Ids (priority_id): 1 Callback Schedule (is_callback = 1), 2 Fresh Assign, 3 Final Disposal (disposed_priority_id, never claimed, rejected on push). Claim order uses priority_no: Fresh Assign 1, Callback Schedule 2, Final Disposal 3. Disposed leads only come back through socket redial, a new CRM push, or a CRM pending callback. A CRM pending disposition also sets Final Disposal with disposeRemark = CRM: <reason>.
Config that actually moves the needle
| Setting | Used? | Meaning |
|---|---|---|
dialer_type | Yes | Progressive or Predictive |
buffer_time | Yes | Wrap seconds |
predictive_ratio | Yes | Customer legs per idle agent |
decline_cooldown_seconds | Yes | Decline block on the same hold |
max_lines | Yes | Cap ringing + hold + connecting |
max_tries / retry_pattern | Yes | Not Connected only (live: 20 tries, pattern [4,4,3,2,1,…]) |
retry_seconds | Yes | 2nd+ NC same-day gap and Abandoned wait (live: 3600). First NC is fixed at 10 minutes |
work_* / outbound_obey_work_hours | Yes | Retry window and optional outbound hour gate (live window 09:30–21:30; obey flag default 0) |
disposed_priority_id | Yes | Final Disposal — never auto-claimed |
fresh_lead_limit (sales_dialer_employee, per agent) | Yes | Daily IST cap on untouched Fresh Assign allotments: NULL unlimited, 0 none, N max per day. See Fresh lead allotment |
isMaintainance | Yes | 1 pauses new floor calls; live calls stay up |
MISSED_ACTIVITY_ENABLED (.env) | Yes | 0 disables the missed-activity outbound block (default 1) |
MISSED_ACTIVITY_GRACE_MINUTES (.env) | Yes | Minutes after a bridged call before it blocks outbound (default 10) |
STICKY_WINDOW_MINUTES / STICKY_NC_TRIES (.env) | Yes | Sticky pin window (default 60) and NC cap before clear (default 3) |
CALL_WEBHOOK_* (.env) | Optional | Hangup webhook; off unless CALL_WEBHOOK_ENABLED=true |
hold_timeout_seconds | No | Unused leftover |
max_abandon_rate | No | Unused leftover |