Hi Rasa community,
I’m confused by a problem:
When I activate a form with inform intent and want to set the first requested slot with role, it’s not working. More specific, this slot will be set after the requested_slot is set, so bot will ask again for this slot.
For example the form is activated with this utterance: I want to order a [blue](req_color) sofa for [4]{"entity": "custom_number", "role": "req_size_num_persons"} people, it give the following action history, this utterance will be validated twice and req_size_num_persons slot is set in the second validation. However, the next requested_slot is still req_size_num_persons, so the form ask again for the req_size_num_persons, even though this slot is already set. And the next message from user to set the slot req_size_num_persons will be then fully ignored.
This problem happens only with slots which should be extracted from roles. For other slots which are extracted from entities, there is no problem.
Tracker slots : {'appoint_time': None, 'req_color': 'blue', 'req_feet': None, 'req_is_placed_at_wall': None, 'req_material': None, 'req_price': None, 'req_price_ma
x': None, 'req_price_min': None, 'req_shape': None, 'req_size': None, 'req_size_depth': None, 'req_size_height': None, 'req_size_length': None, 'req_size_num_perso
ns': None, 'req_size_width': None, 'req_sleep_function': None, 'req_stuffing': None, 'req_style': None, 'req_wood': None, 'requested_slot': None}
Validations : [{'event': 'slot', 'timestamp': None, 'name': 'req_color', 'value': 'blue'}]
ask next: req_size_num_persons
Tracker slots : {'appoint_time': None, 'req_color': 'blue', 'req_feet': None, 'req_is_placed_at_wall': None, 'req_material': None, 'req_price': None, 'req_price_ma
x': None, 'req_price_min': None, 'req_shape': None, 'req_size': None, 'req_size_depth': None, 'req_size_height': None, 'req_size_length': None, 'req_size_num_perso
ns': '4', 'req_size_width': None, 'req_sleep_function': None, 'req_stuffing': None, 'req_style': None, 'req_wood': None, 'requested_slot': None}
Validations : [{'event': 'slot', 'timestamp': None, 'name': 'req_size_num_persons', 'value': '4'}, {'event': 'slot', 'timestamp': None, 'name': 'req_color', 'value
': 'blue'}]
ask next: req_size
Custom Action:
class ValidateCouchRequirementsForm(FormValidationAction):
internal_tracker = {}
def name(self) -> Text:
return "validate_couch_requirements_form"
async def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
vals = await super().run(dispatcher, tracker, domain)
# Dynamically set which and how many slots should be asked for
required_slots = ["req_size_num_persons"] + ValidateCouchRequirementsForm.get_req_size_slots(tracker) \
+ ["req_color", "req_sleep_function", "req_is_placed_at_wall", "req_shape",
"req_material", "req_stuffing", "req_style"] + \
ValidateCouchRequirementsForm.get_price_slots(tracker)
print("Tracker slots : {}".format(tracker.slots))
print("Validations : {}".format(vals))
for slot_name in required_slots:
if tracker.slots.get(slot_name) is None or [val for val in vals
if (val["name"]==slot_name and val["value"]==None)]:
# The slot is not filled yet. Request the user to fill this slot next.
print("ask next: " + slot_name)
return [SlotSet("requested_slot", slot_name)] + vals
# All slots are filled.
return [SlotSet("requested_slot", None)] + vals
Part of Domain file
entities:
- custom_number:
roles:
- req_size_num_persons
- req_size
- req_size_length
- req_size_width
- req_price
- req_price_max
- req_price_min
....
slots:
req_size_num_persons:
type: float
max_value: 12
min_value: 1
influence_conversation: false
This happens really weird to me. Could someone help me with this problem? Thanks a lot!

