mirror of
https://github.com/marcogll/talia_bot.git
synced 2026-01-13 13:25:19 +00:00
@@ -8,4 +8,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
export PYTHONPATH="$PYTHONPATH:$DIR/.."
|
export PYTHONPATH="$PYTHONPATH:$DIR/.."
|
||||||
|
|
||||||
# Run the bot
|
# Run the bot
|
||||||
python3 "$DIR/main.py"
|
python3 "$DIR/talia_bot/main.py"
|
||||||
@@ -115,13 +115,21 @@ class FlowEngine:
|
|||||||
state['collected_data'][f"step_{current_step['step_id']}_response"] = response_data
|
state['collected_data'][f"step_{current_step['step_id']}_response"] = response_data
|
||||||
|
|
||||||
|
|
||||||
next_step_id = state['current_step_id'] + 1
|
# Find the index of the current step to determine the next one robustly
|
||||||
next_step = next((step for step in flow['steps'] if step['step_id'] == next_step_id), None)
|
steps = flow['steps']
|
||||||
|
current_step_index = -1
|
||||||
|
for i, step in enumerate(steps):
|
||||||
|
if step['step_id'] == state['current_step_id']:
|
||||||
|
current_step_index = i
|
||||||
|
break
|
||||||
|
|
||||||
if next_step:
|
# Check if there is a next step in the list
|
||||||
self.update_conversation_state(user_id, state['flow_id'], next_step_id, state['collected_data'])
|
if current_step_index != -1 and current_step_index + 1 < len(steps):
|
||||||
|
next_step = steps[current_step_index + 1]
|
||||||
|
self.update_conversation_state(user_id, state['flow_id'], next_step['step_id'], state['collected_data'])
|
||||||
return {"status": "in_progress", "step": next_step}
|
return {"status": "in_progress", "step": next_step}
|
||||||
else:
|
else:
|
||||||
|
# This is the last step, so the flow is complete
|
||||||
final_data = state['collected_data']
|
final_data = state['collected_data']
|
||||||
self.end_flow(user_id)
|
self.end_flow(user_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user