@akelad need your help here. Thanks
Slots gets extracted but does not get validated using validate_<slot_name>
function.
Following current guidelines here Forms
Logs
2020-10-14 17:06:20 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 297 events.
2020-10-14 17:06:20 DEBUG rasa.core.policies.rule_policy - Predicted loop ‘order_form’.
2020-10-14 17:06:20 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_RulePolicy
2020-10-14 17:06:20 DEBUG rasa.core.processor - Predicted next action ‘order_form’ with confidence 1.00.
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Validating user input ‘UserUttered(text: lays, intent: {‘id’: 3152659454284902011, ‘name’: ‘inform’, ‘confidence’: 0.999991774559021}, entities: [{‘entity’: ‘snack’, ‘start’: 0, ‘end’: 4, ‘confidence_entity’: 0.8661425709724426, ‘value’: ‘lays’, ‘extractor’: ‘DIETClassifier’}])’.
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Trying to extract requested slot ‘snack’ …
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Got mapping ‘{‘type’: ‘from_entity’, ‘entity’: ‘snack’}’
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Successfully extracted ‘lays’ for requested slot ‘snack’
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Validating extracted slots: {‘snack’: ‘lays’}
2020-10-14 17:06:20 DEBUG rasa.core.actions.action - Calling action endpoint to run action ‘validate_order_form’.
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Request next slot ‘size’
and My custom action:
from typing import Dict, Text, List
from rasa_sdk import Tracker
from rasa_sdk.events import EventType
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
from typing import Text, List, Any, Dict
from rasa_sdk import Tracker, FormValidationAction
from rasa_sdk.types import DomainDict
from rasa.shared.core.domain import Domain
class ActionSwitchFAQ(Action):
def name(self) -> Text:
return "action_switch_faq"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
return [SlotSet("detailed_faq", not tracker.get_slot("detailed_faq"))]
class ValidateOrderForm(FormValidationAction, Action):
def name(self) -> Text:
"""Unique identifier of the form"""
return "validate_order_form"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
# dispatcher.utter_message("validate_some_slot")
# return [SlotSet("some_slot", "sdk")]
return []
def validate_snack(
self,
slot_value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict,
) -> Dict[Text, Any]:
"""Validate cuisine value."""
print("Slot Value=", slot_value)
if slot_value == "fries":
print("validation succeeded")
return {"snack": slot_value}
else:
print("validation failed")
# user will be asked for the slot again
return {"snack": None}
def validate_size(
self,
slot_value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict,
) -> Dict[Text, Any]:
"""Validate cuisine value."""
print("Slot Value=", slot_value)
if slot_value == "large":
print("validation succeeded")
return {"size": slot_value}
else:
print("validation failed")
# user will be asked for the slot again
return {"size": None} `