RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.83k stars 4.62k forks source link

FormAction not working to get required field #2372

Closed boredomed closed 5 years ago

boredomed commented 6 years ago
**Rasa Core version*0.9.8*: **Python version*2.7*: **Operating system** (ubuntu 16.04): **Issue**:I am using FormAction to get a required slot named location but its totally not working as the requested_slot does not gets the value location when i run that part of story and then the bot does not replies any thing **bot.py**: ` RANDOMIZE = False @staticmethod def required_field(): return [ EntityFormField("location", "location") ] def name(self): return 'action_search_name' def run(self, dispatcher, tracker, domain): name = tracker.get_slot("r_name") location = tracker.get_slot("location") df = pd.read_csv("yelp_business.csv") result = df.loc[(df['name'].str.contains(name, case = False)) | (df['location'].str.contains(location, case = False)), df.notnull().any(axis = 0)] if result.empty: dispatcher.utter_message("Restaurant address Unavailable :(") else: dispatcher.utter_message("Here's what I found:") y = result["address"].reset_index(drop=True) name = None if y is not None: dispatcher.utter_message("Address :") dispatcher.utter_message(y[0]) return [SlotSet("r_name", None)] ` **Content of domain file** (if used & relevant): ```intents: - greet - restaurant_search - name_search - affirm - goodbye entities: - location - food - cuisine - r_name - requested_slot actions: - utter_greet - utter_affirm - utter_bye - utter_ask_location - bot.ActionCheckRestaurants - bot.ActionSearchName slots: location: type: text food: type: text cuisine: type: text r_name: type: text requested_slot: type: unfeaturized templates: utter_greet: - "Hy there" - "Hi" - "Hy how can i help you" utter_affirm: - "Thanks for using" utter_bye: - "Goodbye" utter_ask_location: - "In which city you want to perform this search?" ``` **stories.md**: ``` ## path3 * greet - utter_greet * restaurant_search{"r_name" : "macdonld"} - slot{"requested_slot":"location"} * restaurant_search{"location": "toronto"} - action_search_name * restaurant_search - action_check_restaurants * affirm - utter_affirm ## path9 * restaurant_search{"r_name" : "macdonld"} - slot{"requested_slot":"location"} - utter_ask_location * restaurant_search{"location": "toronto"} - action_search_name ``` What i can see in debug mood is that when i am at first intent of path9 it does not set the requested slot to location and does not performs any utterance cant get how to make it working.
boredomed commented 6 years ago

@akelad can you please look into the issue

akelad commented 6 years ago

You need to add the formaction after your restaurant_search intent in the stories, because that's the action that sets the slot

boredomed commented 6 years ago

Doing this it still dont utter anything if location is not entered

* restaurant_search{"r_name" : "macdonld"}
  - action_search_name
  - slot{"requested_slot":"location"}

Is the domain file correct ? I have created the utter_ask_location but this dont work is there some genaric syntax that can be used for any slot?

akelad commented 6 years ago

Have you added the utter_ask_location action in that story as well? And actually your path3 story also needs that after the slot event for the requested slot

JoeTorino commented 6 years ago

Have you added the utter_ask_location action in that story as well? And actually your path3 story also needs that after the slot event for the requested slot

Doesn't that defeat the purpose of having a formaction, I thought it was to reduce the number of stories and the number of actions you need to insert in each story?

Is this story correct or do I have to insert a slot{"requested_slot":"citta"}?

akelad commented 6 years ago

I'm not sure what i meant with that comment before anymore. Yes that's the point of the form action, our current implementation doesn't quite achieve that yet though, we're working on a new and improved version at the moment, which you can take a look at here: https://github.com/RasaHQ/rasa_core/pull/1013 As for your story, you need to add the requested_slot yes. I'm gonna close this issue now because there hasn't been a response from the original poster, if you have any more questions about form actions please post on the forum. Or if you have any comments/improvement suggestion for the new implementation then please comment on the PR