DreamStream-1 commited on
Commit
15c20db
Β·
verified Β·
1 Parent(s): fb13613

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1775,7 +1775,7 @@ async def process_incoming_message(from_number: str, msg: dict):
1775
  return
1776
 
1777
  # 🎯 PRIORITY 3: Menu selections - check if this is a valid menu selection for current state
1778
- if current_state in ['main_menu', 'category_selection_menu', 'category_products_menu', 'all_products_menu', 'product_inquiry']:
1779
  # Validate menu selection
1780
  is_valid, error_msg = validate_menu_selection(message_body, current_state, user_context)
1781
 
@@ -1861,6 +1861,23 @@ async def process_incoming_message(from_number: str, msg: dict):
1861
  send_whatsjet_message(from_number, "❌ No products available. Type 'main' to return to main menu.")
1862
  elif current_state == 'product_inquiry':
1863
  await handle_veterinary_product_followup(message_body, from_number)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1864
  return # Exit after handling menu selection
1865
 
1866
  # 🎯 PRIORITY 4: Product names - works from ANY menu state
@@ -3185,6 +3202,14 @@ def get_menu_validation_message(current_state: str, user_context: dict) -> str:
3185
  "β€’ Type a product name (e.g., 'hydropex', 'respira aid plus')\n"
3186
  "β€’ Type 'main' to return to main menu"
3187
  )
 
 
 
 
 
 
 
 
3188
  else:
3189
  return (
3190
  "❌ *Invalid Selection*\n\n"
 
1775
  return
1776
 
1777
  # 🎯 PRIORITY 3: Menu selections - check if this is a valid menu selection for current state
1778
+ if current_state in ['main_menu', 'category_selection_menu', 'category_products_menu', 'all_products_menu', 'product_inquiry', 'intelligent_products_menu']:
1779
  # Validate menu selection
1780
  is_valid, error_msg = validate_menu_selection(message_body, current_state, user_context)
1781
 
 
1861
  send_whatsjet_message(from_number, "❌ No products available. Type 'main' to return to main menu.")
1862
  elif current_state == 'product_inquiry':
1863
  await handle_veterinary_product_followup(message_body, from_number)
1864
+ elif current_state == 'intelligent_products_menu':
1865
+ # Handle product selection from intelligent products menu
1866
+ available_products = user_context.get('available_products', [])
1867
+ if message_body.isdigit() and 1 <= int(message_body) <= len(available_products):
1868
+ selected_product = available_products[int(message_body) - 1]
1869
+ context_manager.update_context(
1870
+ from_number,
1871
+ current_product=selected_product,
1872
+ current_state='product_inquiry',
1873
+ current_menu='product_inquiry',
1874
+ current_menu_options=list(MENU_CONFIG['product_inquiry']['option_descriptions'].values())
1875
+ )
1876
+ await send_product_image_with_caption(from_number, selected_product, user_context)
1877
+ return
1878
+ else:
1879
+ send_whatsjet_message(from_number, get_menu_validation_message(current_state, user_context))
1880
+ return
1881
  return # Exit after handling menu selection
1882
 
1883
  # 🎯 PRIORITY 4: Product names - works from ANY menu state
 
3202
  "β€’ Type a product name (e.g., 'hydropex', 'respira aid plus')\n"
3203
  "β€’ Type 'main' to return to main menu"
3204
  )
3205
+ elif current_state == 'intelligent_products_menu':
3206
+ return (
3207
+ "❌ *Invalid Selection*\n\n"
3208
+ "Please choose a product number between 1 and {len(available_products)}.\n\n"
3209
+ "πŸ’¬ *You can also:*\n"
3210
+ "β€’ Type a product name (e.g., 'hydropex', 'respira aid plus')\n"
3211
+ "β€’ Type 'main' to return to main menu"
3212
+ )
3213
  else:
3214
  return (
3215
  "❌ *Invalid Selection*\n\n"