🔹 Introduction: Making Conversations Feel Human
What if your bot remembered the user’s last product choice or location? Personalized responses = happy users.
🔄 Why Memory Enhances UX:
Users expect continuity. A bot that recalls previous interactions (like selected product or preferred location) provides a personalized, smoother experience.
📦 Session Cache Recommendation:
Store each user’s preferences (e.g., product, location) in a session-based cache like Redis or an in-memory store using unique user identifiers.
🔁 Greeting Logic:
Handle greetings like “hi”, “start”, “restart” to reset the session and clear context. This mimics a fresh conversation.
Entity Extraction Example
def get_product_name(text: str) -> str: product_mappings = { "product a": "Product A", "product b": "Product B" } text_lower = text.lower() for key, name in product_mappings.items(): if key in text_lower: return name return "Unknown Product" def get_location(text: str) -> str: location_mappings = { "location x": "Location X", "location y": "Location Y" } text_lower = text.lower() for key, name in location_mappings.items(): if key in text_lower: return name return None
Session and Template Usage
- Use a session cache to track selected product and location per user.
- Use a used_info_template flag to avoid sending duplicate templates.
Restarting Conversations
greetings = ["hi", "hello", "hey", "start", "restart"] if incoming_text.lower().strip() in greetings: if from_number in token_cache: del token_cache[from_number]
🔹 Engagement Tip:
Bots that remember your preferences outperform generic bots in NPS by 40%. Don’t reset the user every time.
Section Summary
This section focused on giving your chatbot memory—allowing it to recall past user inputs such as selected products or locations. We discussed methods for entity extraction and session management. This layer of personalization is critical for building user trust and delivering a seamless, human-like chat experience.