How to utter validation response for the slots instead of their default response utter_ask_slot_name

rasa (0.0.5) rasa-addons (0.5.5) rasa-core (0.13.2) rasa-core-sdk (0.12.1) rasa-nlu (0.14.3)

Python version : 3.6.7

Operating system (windows, osx, …): Ubuntu

Issue : so to display an information i prompt user to enter id using utter_ask_id for the slot ‘id’. User enters and bot validates it, if it doesn’t get validated bot displays a message using dispatcher.utter_template(“utter_no_id”, tracker), but as the slot is still empty it also displays the second message using utter_ask_id right after the dispatcher message (two messages at the same time). So what i need is the only message from the dispatcher not the message from utter_ask_id. How can i achieve this? Thanks.

Hi @noman,

I’m not sure if this already changed on newer releases of rasa. But in the one I used I solved this problem this way. I made a unfeaturized slot named “retry_question”.

On the validate part of form action:

def validate(self, dispatcher, tracker, domain):

I’ve added a SlotSet to set the retry_question slot to True in case it is invalid:

    if invalid:
        slots.append(SlotSet('retry_question', True))
    else:
        slots.append(SlotSet('retry_question', None))

When failing to validate a slot FormAction will run:

def request_next_slot(self, dispatcher, tracker, domain):

In here what i did was

                if self._should_request_slot(tracker, slot):
                logger.debug("Request next slot '{}'".format(slot))

                if not tracker.get_slot('retry_question'):
                    dispatcher.utter_template("utter_ask_{}".format(slot), tracker)

                return [SlotSet(REQUESTED_SLOT, slot)]

So as you can see when retry_question is True. It will not make the dispatch to utter_ask_id This will avoid the two messages being sent.

Regards,

2 Likes

Thank you so much @custodio, i will look into it.