DreamStream-1 commited on
Commit
78ace92
·
verified ·
1 Parent(s): 78475cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -29
app.py CHANGED
@@ -2063,34 +2063,9 @@ async def process_incoming_message(from_number: str, msg: dict):
2063
  await handle_category_selection(message_body, from_number)
2064
  return
2065
 
2066
- # 🎯 PRIORITY 5: Individual product selection by number
2067
- elif current_state in ['all_products_menu', 'category_products_menu']:
2068
- # Handle product selection from numbered list
2069
- try:
2070
- selection_index = int(message_body) - 1
2071
- menu_options = user_context.get('current_menu_options', [])
2072
- available_products = user_context.get('available_products', [])
2073
-
2074
- if 0 <= selection_index < len(available_products):
2075
- selected_product = available_products[selection_index]
2076
- context_manager.update_context(from_number, current_product=selected_product)
2077
- await send_product_with_image(from_number, selected_product, user_context)
2078
- await handle_veterinary_product_followup(selected_product.get('Product Name', ''), from_number)
2079
- return
2080
- else:
2081
- # Invalid selection
2082
- if reply_language == 'ur':
2083
- send_whatsjet_message(from_number, f"❌ *غلط انتخاب۔ براہ کرم 1 سے {len(available_products)} کے درمیان نمبر منتخب کریں یا 'main' لکھ کر مین مینو پر واپس جائیں۔*")
2084
- else:
2085
- send_whatsjet_message(from_number, f"❌ *Invalid selection. Please choose a number between 1 and {len(available_products)}, or type 'main' to return to main menu.*")
2086
- return
2087
-
2088
- except ValueError:
2089
- # Not a number - treat as general query
2090
- await handle_general_query_with_ai(from_number, message_body, user_context, reply_language)
2091
- return
2092
 
2093
- # 🎯 PRIORITY 6: Product inquiry handling (for direct product searches)
2094
  elif current_state == 'product_inquiry':
2095
  # Check for voice commands first
2096
  mapped_command = process_intelligent_voice_command(message_body, current_state, user_context)
@@ -2179,7 +2154,7 @@ async def process_incoming_message(from_number: str, msg: dict):
2179
  await handle_general_query_with_ai(from_number, message_body, user_context, reply_language)
2180
  return
2181
 
2182
- # 🎯 PRIORITY 7: All other queries - use OpenAI for intelligent response
2183
  await handle_general_query_with_ai(from_number, message_body, user_context, reply_language)
2184
  return
2185
 
@@ -2388,7 +2363,7 @@ async def process_incoming_message(from_number: str, msg: dict):
2388
  return
2389
  return # Exit after handling menu selection
2390
 
2391
- # 🎯 PRIORITY 4: Product names - works from ANY menu state
2392
  # This ensures users can say product names like "hydropex", "respira aid plus", etc. from any menu
2393
  logger.info(f"[Process] Checking for product name in message: '{message_body}' from state: {current_state}")
2394
  products = get_veterinary_product_matches(message_body)
 
2063
  await handle_category_selection(message_body, from_number)
2064
  return
2065
 
2066
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2067
 
2068
+ # 🎯 PRIORITY 5: Product inquiry handling (for direct product searches)
2069
  elif current_state == 'product_inquiry':
2070
  # Check for voice commands first
2071
  mapped_command = process_intelligent_voice_command(message_body, current_state, user_context)
 
2154
  await handle_general_query_with_ai(from_number, message_body, user_context, reply_language)
2155
  return
2156
 
2157
+ # 🎯 PRIORITY 6: All other queries - use OpenAI for intelligent response
2158
  await handle_general_query_with_ai(from_number, message_body, user_context, reply_language)
2159
  return
2160
 
 
2363
  return
2364
  return # Exit after handling menu selection
2365
 
2366
+ # 🎯 PRIORITY 6: Product names - works from ANY menu state
2367
  # This ensures users can say product names like "hydropex", "respira aid plus", etc. from any menu
2368
  logger.info(f"[Process] Checking for product name in message: '{message_body}' from state: {current_state}")
2369
  products = get_veterinary_product_matches(message_body)