Update app.py
Browse files
app.py
CHANGED
|
@@ -443,20 +443,20 @@ async def process_order_flow(user_id: str, message: str) -> str:
|
|
| 443 |
return f"You selected {found_dish}. How many servings would you like?"
|
| 444 |
|
| 445 |
# If state exists and we're already in order flow:
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
return (f"You selected {found_dish} with {quantity} serving(s). "
|
| 461 |
"Please provide your phone number and delivery address.")
|
| 462 |
else:
|
|
|
|
| 443 |
return f"You selected {found_dish}. How many servings would you like?"
|
| 444 |
|
| 445 |
# If state exists and we're already in order flow:
|
| 446 |
+
if state and state.flow == "order":
|
| 447 |
+
state.update_last_active()
|
| 448 |
+
if state.step == 1:
|
| 449 |
+
# Use fuzzy matching on the message in case of typos.
|
| 450 |
+
found_dish = match_dish(message)
|
| 451 |
+
numbers = re.findall(r'\d+', message)
|
| 452 |
+
if found_dish:
|
| 453 |
+
state.data["dish"] = found_dish
|
| 454 |
+
if numbers:
|
| 455 |
+
quantity = int(numbers[0])
|
| 456 |
+
if quantity <= 0:
|
| 457 |
+
return "Please enter a valid quantity (e.g., 1, 2, 3)."
|
| 458 |
+
state.data["quantity"] = quantity
|
| 459 |
+
state.step = 3
|
| 460 |
return (f"You selected {found_dish} with {quantity} serving(s). "
|
| 461 |
"Please provide your phone number and delivery address.")
|
| 462 |
else:
|