Hello everyone !
In my start-up we are developing a tool to retrieve information about drug treatments. In particular the dose of medication taken by the patient.
To do this, I use FormActions. This is the one I have a problem with today:
class TreatmentDosing(FormAction):
	def name(self):
		return "form_treatment_dosing"
	@staticmethod
	def required_slots(tracker):
		return ["treatment_dosing"]
	def slot_mappings(self):
		return {"treatment_dosing": [self.from_entity(entity="dosing"), self.from_entity(entity="QUANTITY"), self.from_entity(entity="CARDINAL"), self.from_entity(entity="number")]}
	def validate(self, dispatcher, tracker, domain):
		debug(dispatcher, tracker)
		slot_values = self.extract_other_slots(dispatcher, tracker, domain)
		for slot, value in slot_values.items():
			if slot == 'treatment_dosing':
				if tracker.get_slot('dosing') is not None:
					slot_values["treatment_dosing"] = tracker.get_slot('dosing')
				elif tracker.get_slot('QUANTITY') is not None:
					slot_values["treatment_dosing"] = tracker.get_slot('QUANTITY')
				elif tracker.get_slot('CARDINAL') is not None:
					slot_values["treatment_dosing"] = tracker.get_slot('CARDINAL')
		slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
		if slot_to_fill:
			slot_values.update(self.extract_requested_slot(dispatcher, tracker, domain))
			if not slot_values:
				intent =  tracker.latest_message['intent'].get('name')
				if intent == "stop" or intent == "deny" or intent == "affirm" or intent == "reset1":
					raise ActionExecutionRejection(self.name(), "Failed to validate slot {0}" "with action {1}" "".format(slot_to_fill, self.name()))
				else:
					return []
		return [SlotSet(slot, value) for slot, value in slot_values.items()]
	def submit(self, dispatcher, tracker, domain):
		dispatcher.utter_message("I got it, it's "+str(tracker.get_slot("treatment_dosing"))+" of "+str(tracker.get_slot("drug"))+".")
		return [SlotSet("drug", None), SlotSet("treatment_dosing", None)]
The problem is that when I say a sentence like “I take 20mg of xanax”. The form asks me how much medication I am taking when I am already answering the question in the previous sentence. I have many unfeaturized slots as in the documentation.
I don’t know how to do… I already tried the slot_mapping method, force the values in the validation, etc. Any ideas ?
