I’m trying to set slots in a custom action and run the template but template does not have update slot values. I’ve tried multiple ways to get this approach working but failed. After updating the slots template does not get the latest values in slot and shows None
.
class Call(Action):
def name(self):
return "action_call_user"
def run(self, dispatcher, tracker, domain):
user_type = tracker.get_slot("user_type")
if user_type in ["Doctor", "dr." "doctor", "dr", "Dr.", "DOCTOR"]:
tracker.slots['doctor_name'] = tracker.get_slot("given_name")
tracker.slots['doctor_lastname'] = tracker.get_slot("given_lastname")
print(tracker.slots['doctor_name'])
print(tracker.slots['doctor_lastname'])
dispatcher.utter_template("utter_navigate_call_doctor", tracker)
# return [SlotSet("doctor_name", tracker.get_slot("given_name")),
# SlotSet("doctor_lastname", tracker.get_slot("given_lastname"))]
return []
elif user_type in ["patient", "PATIENT"]:
tracker.slots['patient_name'] = tracker.get_slot("given_name")
tracker.slots['patient_lastname'] = tracker.get_slot("given_lastname")
print(tracker.slots['patient_name'])
print(tracker.slots['patient_lastname'])
dispatcher.utter_template("utter_navigate_call_patient", tracker)
# return [SlotSet("patient_name", tracker.get_slot("given_name")),
# SlotSet("patient_lastname", tracker.get_slot("given_lastname"))]
return []
else:
dispatcher.utter_template("utter_navigate_call_follow_up_user", tracker)
Although slot values are being set but template does not get the updated values.
Templates:
utter_navigate_call_patient:
- "Calling {user_type} {patient_name}."
utter_navigate_call_doctor:
- "Calling {user_type} {doctor_name}."
Output:
call patient Usman Sharif
2018-10-04 12:24:03 DEBUG rasa_core.tracker_store - Recreating tracker for id 'default'
2018-10-04 12:24:03 DEBUG rasa_core.processor - Received user message 'call patient Usman Sharif' with intent '{'name': 'navigate.call', 'confidence': 0.9449410438537598}' and entities '[{'start': 0, 'end': 4, 'value': 'call', 'entity': 'command', 'confidence': 0.9565597808990413, 'extractor': 'ner_crf'}, {'start': 5, 'end': 12, 'value': 'patient', 'entity': 'user_type', 'confidence': 0.9367968120048038, 'extractor': 'ner_crf'}, {'start': 13, 'end': 18, 'value': 'Usman', 'entity': 'given_name', 'confidence': 0.9641212606072291, 'extractor': 'ner_crf'}, {'start': 19, 'end': 25, 'value': 'Sharif', 'entity': 'given_lastname', 'confidence': 0.9144945934024098, 'extractor': 'ner_crf'}]'
2018-10-04 12:24:03 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 26 events
2018-10-04 12:24:03 DEBUG rasa_core.processor - Current slot values:
command: call
diastolic: None
doctor_lastname: None
doctor_name: None
given_lastname: Sharif
given_name: Usman
head_length: None
head_unit: None
height_length: None
height_unit: in
navModule: None
patient_lastname: None
patient_name: None
pulse_rate: None
respiration_rate: None
saturation_level: None
systolic: None
temperature_method: None
temperature_unit: Celsius
temperature_value: None
user_type: patient
vitModule: None
waist_length: None
waist_unit: in
weight_unit: lbs
weight_value: None
2018-10-04 12:24:03 DEBUG rasa_core.policies.memoization - Current tracker state [{'slot_waist_unit_0': 1.0, 'entity_user_type': 1.0, 'prev_action_slot_reset': 1.0, 'entity_given_name': 1.0, 'entity_given_lastname': 1.0, 'intent_navigate.call': 1.0, 'slot_weight_unit_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_temperature_unit_0': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'prev_action_listen': 1.0, 'entity_given_name': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'entity_given_name': 1.0, 'prev_action_call_user': 1.0}, {'slot_waist_unit_0': 1.0, 'entity_user_type': 1.0, 'prev_action_slot_reset': 1.0, 'entity_given_name': 1.0, 'entity_given_lastname': 1.0, 'intent_navigate.call': 1.0, 'slot_weight_unit_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_temperature_unit_0': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'prev_action_listen': 1.0, 'entity_given_name': 1.0}]
2018-10-04 12:24:03 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-04 12:24:03 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_KerasPolicy
2018-10-04 12:24:03 DEBUG rasa_core.processor - Predicted next action 'action_call_user' with prob 1.00.
2018-10-04 12:24:03 DEBUG rasa_core.actions.action - Calling action endpoint to run action 'action_call_user'.
2018-10-04 12:24:03 DEBUG rasa_core.processor - Action 'action_call_user' ended with events '[]'
2018-10-04 12:24:03 DEBUG rasa_core.processor - Bot utterance 'BotUttered(text: Calling patient None., data: {
"elements": null,
"buttons": null,
"attachment": null
})'
2018-10-04 12:24:03 DEBUG rasa_core.policies.memoization - Current tracker state [{'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'prev_action_listen': 1.0, 'entity_given_name': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'entity_given_name': 1.0, 'prev_action_call_user': 1.0}, {'slot_waist_unit_0': 1.0, 'entity_user_type': 1.0, 'prev_action_slot_reset': 1.0, 'entity_given_name': 1.0, 'entity_given_lastname': 1.0, 'intent_navigate.call': 1.0, 'slot_weight_unit_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_temperature_unit_0': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'prev_action_listen': 1.0, 'entity_given_name': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'entity_given_name': 1.0, 'prev_action_call_user': 1.0}]
2018-10-04 12:24:03 DEBUG rasa_core.policies.memoization - There is no memorised next action
Calling patient None.
2018-10-04 12:24:03 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_KerasPolicy
2018-10-04 12:24:03 DEBUG rasa_core.processor - Predicted next action 'action_slot_reset' with prob 1.00.
2018-10-04 12:24:03 DEBUG rasa_core.actions.action - Calling action endpoint to run action 'action_slot_reset'.
2018-10-04 12:24:03 DEBUG rasa_core.processor - Action 'action_slot_reset' ended with events '['AllSlotsReset()']'
2018-10-04 12:24:03 DEBUG rasa_core.policies.memoization - Current tracker state [{'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'entity_given_name': 1.0, 'prev_action_call_user': 1.0}, {'slot_waist_unit_0': 1.0, 'entity_user_type': 1.0, 'prev_action_slot_reset': 1.0, 'entity_given_name': 1.0, 'entity_given_lastname': 1.0, 'intent_navigate.call': 1.0, 'slot_weight_unit_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_temperature_unit_0': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'prev_action_listen': 1.0, 'entity_given_name': 1.0}, {'entity_user_type': 1.0, 'slot_user_type_0': 1.0, 'intent_navigate.call': 1.0, 'slot_given_name_0': 1.0, 'slot_command_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_waist_unit_0': 1.0, 'slot_temperature_unit_0': 1.0, 'slot_given_lastname_0': 1.0, 'entity_given_lastname': 1.0, 'slot_weight_unit_0': 1.0, 'entity_given_name': 1.0, 'prev_action_call_user': 1.0}, {'slot_waist_unit_0': 1.0, 'entity_user_type': 1.0, 'prev_action_slot_reset': 1.0, 'entity_given_name': 1.0, 'entity_given_lastname': 1.0, 'intent_navigate.call': 1.0, 'slot_weight_unit_0': 1.0, 'entity_command': 1.0, 'slot_height_unit_0': 1.0, 'slot_temperature_unit_0': 1.0}]
2018-10-04 12:24:03 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-04 12:24:03 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_KerasPolicy
2018-10-04 12:24:03 DEBUG rasa_core.processor - Predicted next action 'action_listen' with prob 1.00.
2018-10-04 12:24:03 DEBUG rasa_core.processor - Action 'action_listen' ended with events '[]'
127.0.0.1 - - [2018-10-04 12:24:03] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 189 0.162248