Lead Reassignment
The Lead Reassignment system (ReassignFollowupCallsBO.cs) ensures that no lead falls through the cracks when a telecaller becomes unavailable. It provides automated overdue detection, manager-initiated reassignment, and bulk operations for leave management and terminations.
Reassignment Triggers
Overdue Detection System
The system continuously monitors scheduled follow-up calls to identify overdue leads.
Overdue Criteria
A lead is flagged as "overdue for reassignment" when:
- Scheduled Follow-up Date Passed: The CB (Call Back) or scheduled follow-up date is in the past
- No Follow-up Action: The assigned TC has not updated the lead status in the defined window
- Window Duration: Default 24 hours past scheduled date, configurable per TeleLeader
SELECT LeadId, StaffId, ScheduledDate, LastUpdate
FROM FollowupCalls
WHERE ScheduledDate < DATEADD(HOUR, -24, GETDATE())
AND LastUpdate < DATEADD(HOUR, -24, GETDATE())
AND StaffId IS NOT NULL
AND Status IN ('CB', 'WBD', 'CP')Overdue Detection Flowchart
Manager-Initiated Reassignment
TeleLeaders (team managers) can manually reassign leads between their managed telecallers.
Reassignment Process
Authorization via TeleLeaderManager Cache
The system uses a 15-minute cached lookup to validate reassignment authorization:
TeleLeaderManager Cache:
├─ Key: TeleLeaderId
├─ Value: Set of ManagedStaffIds
├─ TTL: 15 minutes
└─ Refresh: On login or explicit refresh
Validation Logic:
When TL reassigns lead to TC:
├─ Lookup: TeleLeaderManager[TL_Id] → Set of managed staff
├─ Check: Is TC in managed set?
├─ Result: Allow if YES, Reject if NO
└─ Log: Authorization decisionCache Refresh Triggers:
- On TeleLeader login
- When team membership changes
- Every 15 minutes (automatic)
- Manual refresh option in UI
Bulk Reassignment Operations
When a telecaller goes on leave or is terminated, all their active leads must be reassigned to maintain continuity.
Bulk Reassignment Scenarios
Bulk Reassignment Process
When a TC goes on leave or is terminated:
BULK REASSIGNMENT WORKFLOW:
1. Identify Affected Leads:
SELECT * FROM FollowupCalls
WHERE StaffId = @tcId AND Status IN ('CB', 'CP', 'WBD')
2. Calculate Reassignment Pool:
├─ Get all TCs in same TeleLeader's team
├─ Exclude: On leave, terminated, inactive
├─ Exclude: At capacity (max leads per TC)
└─ Sort by: Current load (ascending)
3. Distribute Leads:
├─ Balance across available TCs
├─ Prefer geographic proximity (if tracked)
├─ Prefer domain expertise (if available)
└─ Last resort: Round-robin assignment
4. Log Reassignment:
INSERT INTO ReassignmentLog (
OldStaffId, NewStaffId, LeadId,
TeleLeaderId, ReasonCode, Timestamp
)
WHERE ReasonCode = 'Leave' or 'Termination'
5. Notify New Assignees:
FOR EACH assigned TC:
SEND Notification: "[X] leads reassigned due to [Reason]"
6. Mark for Follow-up:
FOR EACH reassigned lead:
CREATE Reminder: "Follow-up due [scheduled_date]"Data Models & Logging
FollowupCalls Table
| Column | Type | Purpose |
|---|---|---|
| FollowupCallId | INT PK | Primary key |
| LeadId | INT FK | References Lead |
| StaffId | INT FK | Current assigned TC |
| ScheduledDate | DATETIME | When follow-up is due |
| LastUpdate | DATETIME | Last status change |
| Status | VARCHAR(50) | Lead status code |
| WindowHours | INT | Hours before considered overdue |
| OriginalStaffId | INT | Original assigning TC |
ReassignmentLog Table
| Column | Type | Purpose |
|---|---|---|
| ReassignmentLogId | INT PK | Primary key |
| LeadId | INT FK | Lead being reassigned |
| StaffId_From | INT FK | Previous TC |
| StaffId_To | INT FK | New TC |
| TeleLeaderId | INT FK | Manager who authorized |
| ReasonCode | VARCHAR(50) | 'Manual', 'Overdue', 'Leave', 'Termination' |
| ReasonDetails | NVARCHAR(MAX) | Additional context |
| ReassignedDate | DATETIME | When reassignment occurred |
| Approved | BIT | Manual approvals only |
Business Rules
- Authorization Required: Only TeleLeaders can reassign their managed TCs' leads
- Team Boundary: A TeleLeader cannot reassign to TCs outside their team (cached authorization prevents this)
- Bulk Consistency: All leads from a departing TC are reassigned within the same transaction
- Preservation of History: Original assigning TC is logged in FollowupCalls.OriginalStaffId
- Overdue Window: Configurable per TeleLeader, default 24 hours past scheduled date
- Cache Validity: Authorization is cached for 15 minutes; membership changes require manual refresh
- Audit Trail: All reassignments are logged with reason, timestamp, and authorizer ID
Reassignment Decision Flowchart
Performance Considerations
- Overdue Detection: Runs every 4 hours via scheduled job
- Cache Efficiency: 15-minute TTL reduces database hits for TeleLeaderManager lookups
- Bulk Operations: Processed in batches of 100 leads per transaction for stability
- Index Strategy: Indexes on (StaffId, ScheduledDate, Status) optimize overdue queries
- Notification Queue: Async notifications prevent UI blocking during bulk reassignments
Monitoring & Alerts
- Overdue Queue Size: Alert if > 50 leads pending reassignment per team
- Reassignment Lag: Track time from overdue detection to reassignment
- Authorization Failures: Log and review denied reassignments
- Cache Refresh Failures: Alert if TeleLeaderManager cache cannot refresh