Hi
I have been trying to implement forms in rasa 2.1.3. I am filling all the slot with custom slot mapping and according to documentation here, i should only mention slots that use pre-defined mapping in the domain.yml. so here is what my domain.yml looks like for forms.
slots:
avdt_flag:
type: text
influence_conversation: true
forms:
comparison_form
responses:
utter_begin_comparison:
- text: Lets compare!
But this is not working. None of my required slots are getting filled. Here is my actions.py.
class AskForSlotActionCompareWhat(Action):
def name(self) -> Text:
return "action_ask_compare_what"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
metric_candidates = ['visits', 'visitors']
button_info = {"1": metric_candidates}
message, buttons = button_shower(
self.name(),
button_info,
tag="1"
)
print(message)
print(buttons)
dispatcher.utter_message(
text=message,
buttons=buttons)
return []
class AskForSlotActionCompareFrom(Action):
def name(self) -> Text:
return "action_ask_compare_from"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
tscale_candidates = list(format_timescale.data.get(
"comparison_timeperiods").keys())
button_info = {"1": tscale_candidates}
message, buttons = button_shower(
self.name(),
button_info,
tag="1"
)
dispatcher.utter_message(
text="",
buttons=buttons)
return []
class AskForSlotActionCompareWith(Action):
def name(self) -> Text:
return "action_ask_compare_with"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
tscale_candidates = list(format_timescale.data.get(
"comparison_timeperiods").keys())
button_info = {"1": tscale_candidates}
message, buttons = button_shower(
self.name(),
button_info,
tag="1"
)
dispatcher.utter_message(
text="",
buttons=buttons)
return []
class ValidateComparisonForm(FormValidationAction):
def name(self) -> Text:
return "validate_comparison_form"
async def required_slots(
self,
slots_mapped_in_domain: List[Text],
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict,
) -> Optional[List[Text]]:
required_slots = ["compare_what", "compare_from", "compare_with"]
return required_slots
async def extract_compare_what(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
# get the entities
extracted_ents = CustomEntityExtractor.get_entity(
tracker.latest_message['entities'])
what_compare = extracted_ents.get('what_compare')
return {"compare_what": what_compare}
async def extract_compare_from(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
# get the entities
extracted_ents = CustomEntityExtractor.get_entity(
tracker.latest_message['entities'])
from_compare = extracted_ents.get('from_compare')
return {"compare_from": from_compare}
async def extract_compare_with(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
# get the entities
extracted_ents = CustomEntityExtractor.get_entity(
tracker.latest_message['entities'])
with_compare = extracted_ents.get('with_compare')
return {"compare_with": with_compare}
class ActionSubmitComparisonForm(Action):
def name(self) -> Text:
return "ca_submit_comparison_form"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text="Running requested comparison")
@akelad Is there something missing as its not working. Not even the actions to ask for slots are getting executed. How to make it work? I also checked this issue on github issue but its not clear.