Subversion Repositories SmartDukaan

Rev

Rev 37035 | Rev 37047 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37035 Rev 37036
Line 78... Line 78...
78
    private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
78
    private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
79
 
79
 
80
    /** Source / createdBy label for leads captured by the AI assistant (chat + voice). */
80
    /** Source / createdBy label for leads captured by the AI assistant (chat + voice). */
81
    private static final String AI_LEAD_SOURCE = "AI Assistant";
81
    private static final String AI_LEAD_SOURCE = "AI Assistant";
82
 
82
 
-
 
83
    // AI leads are auto-assigned round-robin (one by one) between these two auth users (was hardcoded 53 / Shankar Mushran).
-
 
84
    private static final int AI_ASSIGN_KHUSHBU = 134;  // Khushbu Saxena (khushbu@smartdukaan.com)
-
 
85
    private static final int AI_ASSIGN_ARCHANA = 126;  // Archana Ramola (archana@smartdukaan.com)
-
 
86
    private final java.util.concurrent.atomic.AtomicInteger aiAssignToggle = new java.util.concurrent.atomic.AtomicInteger(0);
-
 
87
 
83
    @Value("${ai.lead.intake.token:}")
88
    @Value("${ai.lead.intake.token:}")
84
    private String aiLeadIntakeToken;
89
    private String aiLeadIntakeToken;
85
 
90
 
86
    /**
91
    /**
87
     * AI-assistant lead intake, hosted in the fofo app so it deploys via {@code fofo_deploy}. Mirrors the
92
     * AI-assistant lead intake, hosted in the fofo app so it deploys via {@code fofo_deploy}. Mirrors the
Line 147... Line 152...
147
        String recordingUrl = aiLeadRequest.getRecordingUrl();
152
        String recordingUrl = aiLeadRequest.getRecordingUrl();
148
        if (recordingUrl != null && !recordingUrl.trim().isEmpty()) {
153
        if (recordingUrl != null && !recordingUrl.trim().isEmpty()) {
149
            lead.setRecordingUrl(recordingUrl.trim());
154
            lead.setRecordingUrl(recordingUrl.trim());
150
        }
155
        }
151
 
156
 
-
 
157
        // Round-robin between Khushbu and Archana, one lead at a time (toggle only advances on a real create, not dedup hits).
-
 
158
        int assignTo = (aiAssignToggle.getAndIncrement() % 2 == 0) ? AI_ASSIGN_KHUSHBU : AI_ASSIGN_ARCHANA;
152
        lead.setAssignTo(53);
159
        lead.setAssignTo(assignTo);
153
        lead.setAuthId(lead.getAssignTo());
160
        lead.setAuthId(lead.getAssignTo());
154
        lead.setCreatedTimestamp(LocalDateTime.now());
161
        lead.setCreatedTimestamp(LocalDateTime.now());
155
        lead.setUpdatedTimestamp(LocalDateTime.now());
162
        lead.setUpdatedTimestamp(LocalDateTime.now());
156
        leadRepository.persist(lead);
163
        leadRepository.persist(lead);
157
 
164
 
158
        LOGGER.info("AI lead intake: created lead id={} for mobile {}", lead.getId(), mobile);
165
        LOGGER.info("AI lead intake: created lead id={} for mobile {}, assigned to authId={}", lead.getId(), mobile, assignTo);
159
        return aiLeadResponse(HttpStatus.OK, "200", "OK", "SUCCESS", lead.getId());
166
        return aiLeadResponse(HttpStatus.OK, "200", "OK", "SUCCESS", lead.getId());
160
    }
167
    }
161
 
168
 
162
    private ResponseEntity<Map<String, Object>> aiLeadResponse(HttpStatus status, String statusCode,
169
    private ResponseEntity<Map<String, Object>> aiLeadResponse(HttpStatus status, String statusCode,
163
                                                               String statusMessage, String responseStatus, Object response) {
170
                                                               String statusMessage, String responseStatus, Object response) {