Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.mistralai.MistralAiChatModel;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.*;
Expand Down Expand Up @@ -70,7 +71,9 @@ public void processMessage(String payload) throws JsonProcessingException {
}
}

private void handleInitialState(String channelId, String message) throws JsonProcessingException {
private Map<String, String> handleInitialState(String channelId, String message) throws JsonProcessingException {
Map<String, String> responsePayload = new HashMap<>();

if (isSaleAgentCalled(message)) {
conversationStates.put(channelId, ConversationState.AWAITING_DETAILS);
String prompt = String.format("""
Expand All @@ -81,10 +84,16 @@ private void handleInitialState(String channelId, String message) throws JsonPro
'Hi, to ensure accurate research, please confirm the business type and the specific location you're targeting,
along with any desired company size criteria.'
Text: '%s'"
""",message);
""", message);
String response = chatModel.call(prompt);
telexClient.sendInstruction(channelId, response);

responsePayload.put("channelId", channelId);
responsePayload.put("message", response);
responsePayload.put("state", "AWAITING_DETAILS");
}

return responsePayload;
}

private void handleDetailsInput(String channelId, String message) throws JsonProcessingException {
Expand Down Expand Up @@ -172,7 +181,7 @@ private void generateAndSendResearch(String channelId, LeadDetails details) thro

} catch (Exception e) {
log.error("Research generation failed", e);
telexClient.sendInstruction(channelId, "I couldn't complete the research. Please try again.");
telexClient.failedInstruction(channelId, "I couldn't complete the research. Please try again.");
}
}

Expand All @@ -183,9 +192,7 @@ private List<String> generatePitches(LeadDetails details, List<RapidLeadDto> lea
Pitch
---
I hope this message finds you well. I lead [Company name] - a firm dedicated to helping %s companies %s.

We understand that every business faces unique challenges, and our tailored approach has empowered companies like [Example Client]. We specialize in [specific service] and believe we could add significant value to your operations.

Would you be available for a brief call next week to discuss how we might support your goals?
""",
details.getCompanySizes(),
Expand All @@ -194,7 +201,6 @@ private List<String> generatePitches(LeadDetails details, List<RapidLeadDto> lea
Generate a short pitch personalized for %s , a %s company, located in %s. Also create a place for my name \s
and my company.
use sample pitch to improve your response.

sample pitch : %s
""",
lead.getName(),
Expand Down