I want to take the name as an input from the user and prompt it to the user as “Hello {Name}”. I dont want to specify any entity as name can be virtually anything.
I’m wanting to know the same thing, I’ve been stuck on this for a little while.
I solved this by using Form action as follows: It will set the name in a slot which can be used later. Please note using form action requires FormPolicy to be set in config.yml
class FacilityForm(FormAction):
"""Custom form action to fill all slots required to find specific type
of healthcare facilities in a certain city or zip code."""
def name(self) -> Text:
"""Unique identifier of the form"""
return "user_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return ["username","location"]
def slot_mappings(self) -> Dict[Text, Any]:
return {
"username": [self.from_text(intent=None), self.from_text()],
"location": [self.from_entity(entity="location", intent="inform"), self.from_text()]
}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],) -> List[Dict]:
"""Define what the form has to do
after all required slots are filled"""
print("username:"+ tracker.get_slot('username'))
print("location:"+ tracker.get_slot('location'))
#dispatcher.utter_message(template="utter_submit")
return []