Business Challenge
An e-commerce giant needs to automate 50,000+ daily inquiries while maintaining >90% CSAT. The system must handle multi-turn conversations, recognize intents accurately, and escalate when necessary.
System Design
The solution involves an input processor, an NLU engine for intent classification, a dialogue manager for state tracking, and a dynamic response generator.
Intent Classification
We use ChainOfThought to determine the user's intent and extract relevant entities like Order IDs.
class IntentClassifier(dspy.Module):
def __init__(self):
self.classify = dspy.ChainOfThought(IntentClassifierSignature)
def forward(self, message, history):
return self.classify(message=message, conversation_history=history)
Dialogue Management
Managing the state of the conversation is key. The Dialogue Manager decides the next action: respond, perform a task (like checking order status), or escalate.
class DialogueManager(dspy.Module):
def forward(self, state, message, intent_result):
# Determine next action based on state and intent
# execute backend actions if needed
pass
Knowledge Integration
The bot queries multiple sources (FAQ, Product DB, Vector Store) to provide accurate answers to general inquiries.