I believe there are times that entity extraction might not do perfect job although it says it “extracted”. So I wanted to incoporate user data confirmation for certain slots. The method I implemented is almost working with one issue and I would like to know:
- If there is better way to handle
- Why there is an issue (slot setting not happening later than desired point) in the approach below.
To Achieve this, I have 2 slots - distance_to_run
and distance_to_run_confirmed
.
First it ask for distance_to_run
. Then next ask for confirmation by emitting
{distance_to_run} is correct?
and the result is set to distance_to_run_confirmed
.
If distance_to_run_confirmed
is set to “no”, then I reset distance_to_run
and distance_to_run_confrimed
to None.
Then it ask for distance_to_run
and distance_to_run_confirmed
again.
This is almost working except that when 2nd time the Bot utter {distance_to_run} is correct?
, the distance_to_run
slot is not set YET.
I think this is similar issue I raised here (When FollowupAction is specified, should all predicted event that has not been executed be reverted?) as if slot setting needs to happen earlier.
Please see the log below and my annotations starts with ‘***’.
*** Here it shows user input is “no” to distance_to_run_confirmed
.
*** It then setting slot value to None from FormAction
*** It then asking distance_to_run
again. All good so far.
There is an active form 'target_pace_form'
You've entered race distance 5. Is this correct?
1: Yes (yes)
2: No (no)
2018-12-17 13:23:55 DEBUG rasa_core.processor - Received user message 'no' with intent '{'name': 'inform', 'confidence': 0.8256822228431702}' and entities '[{'start': 0, 'end': 2, 'value': 'no', 'entity': 'confirm', 'confidence': 0.521670464355981, 'extractor': 'ner_crf'}]'
2018-12-17 13:23:55 DEBUG rasa_core.processor - Current slot values:
distance_to_run: 5
distance_to_run_confirmed: None
2018-12-17 13:23:55 DEBUG rasa_core.processor - Action 'target_pace_form' ended with events '['SlotSet(key: distance_to_run_confirmed, value: None)', 'SlotSet(key: distance_to_run, value: None)', 'SlotSet(key: requested_slot, value: distance_to_run)']'
2018-12-17 13:23:55 DEBUG rasa_core.processor - Bot utterance 'BotUttered(text: What is the race distance?, data: {
"elements": null,
"buttons": null,
"attachment": null
})'
What is the race distance?
*** User input ‘3 miles’
2018-12-17 13:23:57 DEBUG rasa_core.processor - Received user message '3 miles' with intent '{'name': 'inform', 'confidence': 0.970073938369751}' and entities '[{'start': 0, 'end': 7, 'text': '3 miles', 'value': 3, 'confidence': 1.0, 'additional_info': {'value': 3, 'type': 'value', 'unit': 'mile'}, 'entity': 'distance', 'extractor': 'ner_duckling_http'}, {'start': 0, 'end': 1, 'value': '3', 'entity': 'race_distance', 'confidence': 0.5493077740375564, 'extractor': 'ner_crf'}]'
2018-12-17 13:23:57 DEBUG rasa_core.processor - Current slot values:
distance_to_run: None
distance_to_run_confirmed: None
*** Action ended by setting distance_to_run
value to 3
*** Immediately after that, processor utter distance_to_run_confirmed
utterance. Good BUT not perfect.
*** I can confirm that distance_to_run: 3
later in the log but this should take place before the above utterance.
2018-12-17 13:23:57 DEBUG rasa_core.processor - Action 'target_pace_form' ended with events '['SlotSet(key: distance_to_run, value: 3)', 'SlotSet(key: requested_slot, value: distance_to_run_confirmed)']'
2018-12-17 13:23:57 DEBUG rasa_core.processor - Bot utterance 'BotUttered(text: You've entered race distance None. Is this correct?, data: {
"elements": null,
"buttons": [
{
"payload": "yes",
"title": "Yes"
},
{
"payload": "no",
"title": "No"
}
],
"attachment": null
})'
2018-12-17 13:23:57 DEBUG rasa_core.policies.form_policy - There is an active form 'target_pace_form'
You've entered race distance None. Is this correct?
1: Yes (yes)
2: No (no)
2018-12-17 13:23:57 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_1_FormPolicy
2018-12-17 13:23:57 DEBUG rasa_core.processor - Predicted next action 'action_listen' with prob 1.00.
2018-12-17 13:23:57 DEBUG rasa_core.processor - Action 'action_listen' ended with events '[]'
127.0.0.1 - - [2018-12-17 13:23:57] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 334 0.088418
yes
2018-12-17 13:24:01 DEBUG rasa_core.tracker_store - Recreating tracker for id 'default'
2018-12-17 13:24:01 DEBUG rasa_core.processor - Received user message 'yes' with intent '{'name': 'inform', 'confidence': 0.8580890893936157}' and entities '[{'start': 0, 'end': 3, 'value': 'yes', 'entity': 'confirm', 'confidence': 0.5605891169050519, 'extractor': 'ner_crf'}]'
2018-12-17 13:24:01 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 196 events
2018-12-17 13:24:01 DEBUG rasa_core.processor - Current slot values:
distance_to_run: 3
distance_to_run_confirmed: None