zenaight commited on
Commit ·
997047c
1
Parent(s): 928abbc
Add greeting and property interest detection in message processing
Browse files- Enhanced `process_message` to prioritize greeting responses, providing a personalized welcome to users.
- Implemented detection for user interest in specific properties, allowing for tailored responses based on user queries about "property 1" and "property 2."
- Improved overall user engagement by offering detailed information about selected properties, streamlining the interaction flow and enhancing the user experience.
- ai_chat.py +13 -0
ai_chat.py
CHANGED
|
@@ -367,6 +367,19 @@ async def process_message(user_message: str, user_info: dict = None, session_id:
|
|
| 367 |
if user_info is None:
|
| 368 |
user_info = {}
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
# Get user persona
|
| 371 |
persona = await get_or_create_persona(wa_id) if wa_id else {}
|
| 372 |
|
|
|
|
| 367 |
if user_info is None:
|
| 368 |
user_info = {}
|
| 369 |
|
| 370 |
+
# Always handle greetings first, before any property logic
|
| 371 |
+
if user_message.lower() in ["hi", "hello", "hey", "good morning", "good afternoon", "good evening", "morning", "afternoon", "evening"]:
|
| 372 |
+
return f"Hi {user_info.get('name', 'there')}! 👋\n\nI'm your property agent assistant. I can help you find industrial properties, warehouses, offices, and commercial spaces. What are you looking for today?"
|
| 373 |
+
|
| 374 |
+
# Detect if user is expressing interest in a specific property
|
| 375 |
+
property_1_phrases = ["property 1", "first", "1", "one", "office", "19 sqm", "2300", "edenvale"]
|
| 376 |
+
property_2_phrases = ["property 2", "second", "2", "two", "warehouse", "304 sqm", "22000", "rutland"]
|
| 377 |
+
user_response_lower = user_message.lower()
|
| 378 |
+
if any(phrase in user_response_lower for phrase in property_1_phrases):
|
| 379 |
+
return "Great choice! The 19 sqm office space in Eastleigh Exchange is perfect for 2-3 people. It's available for R2,300/month with all-inclusive amenities. Would you like me to tell you more about the features, show you photos, or help you schedule a viewing?"
|
| 380 |
+
if any(phrase in user_response_lower for phrase in property_2_phrases):
|
| 381 |
+
return "Excellent! The 304 sqm warehouse at Rutland Works is ideal for manufacturing. It features high roller shutter access, dual-level layout, and office space. Available for R22,000/month. Would you like more details about the features, photos, or to schedule a viewing?"
|
| 382 |
+
|
| 383 |
# Get user persona
|
| 384 |
persona = await get_or_create_persona(wa_id) if wa_id else {}
|
| 385 |
|