Telecaller & Leads
Call Management
Lead Reassignment

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:

  1. Scheduled Follow-up Date Passed: The CB (Call Back) or scheduled follow-up date is in the past
  2. No Follow-up Action: The assigned TC has not updated the lead status in the defined window
  3. 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 decision

Cache 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

ColumnTypePurpose
FollowupCallIdINT PKPrimary key
LeadIdINT FKReferences Lead
StaffIdINT FKCurrent assigned TC
ScheduledDateDATETIMEWhen follow-up is due
LastUpdateDATETIMELast status change
StatusVARCHAR(50)Lead status code
WindowHoursINTHours before considered overdue
OriginalStaffIdINTOriginal assigning TC

ReassignmentLog Table

ColumnTypePurpose
ReassignmentLogIdINT PKPrimary key
LeadIdINT FKLead being reassigned
StaffId_FromINT FKPrevious TC
StaffId_ToINT FKNew TC
TeleLeaderIdINT FKManager who authorized
ReasonCodeVARCHAR(50)'Manual', 'Overdue', 'Leave', 'Termination'
ReasonDetailsNVARCHAR(MAX)Additional context
ReassignedDateDATETIMEWhen reassignment occurred
ApprovedBITManual approvals only

Business Rules

  1. Authorization Required: Only TeleLeaders can reassign their managed TCs' leads
  2. Team Boundary: A TeleLeader cannot reassign to TCs outside their team (cached authorization prevents this)
  3. Bulk Consistency: All leads from a departing TC are reassigned within the same transaction
  4. Preservation of History: Original assigning TC is logged in FollowupCalls.OriginalStaffId
  5. Overdue Window: Configurable per TeleLeader, default 24 hours past scheduled date
  6. Cache Validity: Authorization is cached for 15 minutes; membership changes require manual refresh
  7. 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