OnlyBiggg commited on
Commit
5a93b14
·
1 Parent(s): d0fa370
Files changed (1) hide show
  1. app/api/routes.py +23 -3
app/api/routes.py CHANGED
@@ -328,13 +328,33 @@ async def time_trip(request: Request) -> Response:
328
  "time_list": time_list
329
  }
330
  text = [" | ".join(map(str, time_list))]
331
- return DialogFlowResponseAPI(text=text)
332
  except Exception as e:
333
  print(e)
334
  return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
335
-
336
- return DialogFlowResponseAPI(parameters=parameters)
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
 
339
  @router.get("/")
340
  def home():
 
328
  "time_list": time_list
329
  }
330
  text = [" | ".join(map(str, time_list))]
331
+ return DialogFlowResponseAPI(text=text, parameters=parameters)
332
  except Exception as e:
333
  print(e)
334
  return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
 
 
335
 
336
+ @router.post('/trip/check-time-select')
337
+ async def is_valid_select_time(request: Request) -> Response:
338
+ try:
339
+ body = await request.json()
340
+ session_info = body.get("sessionInfo", {})
341
+ parameters = session_info.get("parameters")
342
+ time_list: List[Dict[str, any]] = parameters.get("time_list", [])
343
+ raw_input = body.get("text", "")
344
+ if raw_input in time_list:
345
+ parameters = {
346
+ "is_valid_time": True,
347
+ "departure_time": raw_input
348
+ }
349
+ else:
350
+ parameters = {
351
+ "is_valid_time": False
352
+ }
353
+ text = ["Bạn đã chọn thời gian: " + raw_input]
354
+ return DialogFlowResponseAPI(text=text, parameters=parameters)
355
+ except Exception as e:
356
+ print(e)
357
+ return DialogFlowResponseAPI(text=["Hệ thống xảy ra lỗi. Quý khách vui lòng thử lại sau hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."])
358
 
359
  @router.get("/")
360
  def home():