Skip to content

Commit 8a4b56d

Browse files
authored
Merge pull request #194 from PerfectFit-project/update-scheduler-readme
updated readme.md
2 parents 61f8b2f + e789ca4 commit 8a4b56d

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

scheduler/README.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
1+
### StateMachine
2+
The `StateMachine` class is defined in the 'state_machine.py' script. It is in charge of keeping track of the current intervention state. It also receive different types of events as defined in the 'Event' class, and decides which function of the state to activate depending on the event type.
3+
6 events have been defined:
4+
- DIALOG_COMPLETED: a dialog has been completed in Rasa by the user. The completion is tracked and the logic to manage it is activated in the specific state
5+
- DIALOG_RESCHEDULED: a dialog has been rescheduled. The specific state manages the actions to take
6+
- DIALOG_STARTED: a dialog has started. The starting time and the event are tracked
7+
- NEW_DAY: a new day has started. Some of the intervention states take different actions depending on the time dimension.
8+
- USER_TRIGGER = a dialog has been triggered by the user in Rasa. The specific state manages the actions to be taken.
9+
10+
Each user is associated with the instance of a StateMachine.
11+
The state machine is coupled with the `user_state_machine` table on the DB. Every time an event occurs, the state machine is populated with the data stored in the DB, the event is consumed, and the new parameters of the state machine are updated on the DB.
12+
13+
### Controller
14+
In the `controller.py` each possible state is fully defined. Each state is an implementation of the abstract `State` class defined in `state.py`. Each state implements a different logic for managing the events sent by the StateMachine, and defines the rules for changing state.
15+
16+
### celery_tasks
17+
In `celery_tasks.py` the possible celery tasks are defined and implemented. These tasks can be triggered both from Rasa and the states of the state machine.
118
[Celery](https://docs.celeryproject.org/en/stable/) is used to schedule tasks.
219

320
## How to run
421
Start the main application, see instructions in [virtual-coach-main](https://github.com/PerfectFit-project/virtual-coach-main).
522

623
In the Docker output for the Celery worker, you should see something like below:
724
```
8-
scheduler_1 | [2021-10-14 11:34:16,227: INFO/Beat] Scheduler: Sending due task trigger-rasa-reminder (celery_tasks.trigger_rasa_reminder)
9-
scheduler_1 | [2021-10-14 11:34:16,232: INFO/MainProcess] Task celery_tasks.trigger_rasa_reminder[f4c08d73-b866-4640-94be-503483c8e87d] received
10-
niceday_api_1 | POST /messages/ 200 0.982 ms - -
25+
scheduler_1 | [2021-10-14 11:34:16,227: INFO/Beat] Scheduler: Sending due task celery_tasks.trigger_intervention_component (celery_tasks.trigger_rasa_reminder)
26+
scheduler_1 | [2021-10-14 11:34:16,232: INFO/MainProcess] Task celery_tasks.trigger_intervention_component[f4c08d73-b866-4640-94be-503483c8e87d] received
1127
scheduler_1 | [2021-10-14 11:34:16,400: INFO/ForkPoolWorker-2] Task celery_tasks.trigger_rasa_reminder[f4c08d73-b866-4640-94be-503483c8e87d] succeeded in 0.16701790000661276s: None
1228
```
1329
which means Celery works successfully!
14-
15-
So Celery periodically sends a `EXTERNAL_trigger_ask_foreseen_hrs` intent to RASA to trigger RASA to utter `ask_foreseen_hrs` to user.
16-
17-
18-
## How to manually trigger RASA?
19-
Manually trigger RASA to start foreseen HRS conversation
20-
```
21-
curl --location --request POST 'http://localhost:5005/conversations/38527/trigger_intent?output_channel=niceday_trigger_input_channel' \
22-
--header 'Content-Type: application/json' \
23-
--data-raw '{
24-
"name": "EXTERNAL_trigger_ask_foreseen_hrs"
25-
}'
26-
```
27-
You should see a big json response with something like this in it:
28-
```
29-
{"tracker":{"sender_id":"Kees" ...
30-
"latest_message": {
31-
"intent": {
32-
"name": "EXTERNAL_trigger_ask_foreseen_hrs"
33-
},}]}
34-
```

0 commit comments

Comments
 (0)