Form Action asks the same question multiple times

I am beginner and trying to implement form actions. I’m validating my slots where everything is working fine however when my slot validation fails, the failed message as well as the next utter message is displayed multiple times. once i fill in the valid data the slots are getting filled. Functionality wise its working fine but i don’t want the utter messages to be displayed multiple times.

define the name of the method

def name(self) -> Text:
    return "validate_ticketExtraction_form"

define the required slots

@staticmethod
def required_slots(tracker: Tracker)->List[Text]:
     #print("required_slots(tracker: Tracker)")
     return ["xx" , "yy"]

define the slot-intent-entity mapping

def slot_mappings(self):
    #type: type()-> Dict[Text: Union[Dict, List[Dict]]]:
    """A dictionary to map required slots to
        - an extracted entity
        - intent: value pairs
        - a whole message
        or a list of them, where a first match will be picked"""

    return {"xx": self.from_entity(entity="xx",
                                        intent="xxExtraction"),
            "yy": self.from_entity(entity="yy",
                                            intent="yyExtraction")}

define the validation criteria for the slots

def validate_xx(
    self,
    slot_value: Text,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: DomainDict,
) -> Dict[Text, Any]:
    """Validate maildata value."""
    
    if <condition>:
        # validation succeeded, set the value of the "cuisine" slot to value
        return {"xx": slot_value}
    else:
        # validation failed, set this slot to None so that the
        # user will be asked for the slot again
        dispatcher.utter_message(text="The given input is not as per the standard criteria")
        return {"xx": None}

def validate_yy(
    self,
    slot_value: Text,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: DomainDict,
) -> Dict[Text, Any]:
    """Validate ticketnum value."""

    if <condition>:
        # validation succeeded, set the value of the "ticketnum" slot to value
        return {"yy": slot_value}
    else:
        # validation failed, set this slot to None so that the
        # user will be asked for the slot again
        dispatcher.utter_message(text="The given input is not as per the standard criteria")
        return {"yy": None}

define the final action during performing

def submit(self, dispatcher, tracker, domain):
   # type: (CollectingDispatcher, Tracker, Dict[Text, Any]) -> List[Dict]
   """Define what the form has to do
       after all required slots are filled"""

   # utter submit template
   dispatcher.utter_message(text="Submiting Form!   ")
   return []

stories:

version: “2.0”

stories:

  • story: happy path steps:
    • intent: greet
    • action: utter_greet
    • intent: emailExtraction
    • action: ticketExtraction_form
    • active_loop: ticketExtraction_form

rules:

rule: activate ticket extraction form steps:

  • intent: emailExtraction

  • action: ticketExtraction_form

  • active_loop: ticketExtraction_form

  • rule: submit form condition:

    • active_loop: ticketExtraction_form steps:
    • action: ticketExtraction_form
    • active_loop: null
    • slot_was_set:
      • requested_slot: null
    • action: utter_submit

Any help here would be appreciated!! Thanks in advance. Output screenshot below:

There are probably more elaborate ways to do this beside the ones I am suggesting, but I’d go about tackling this in two ways:

  1. Add more alternatives to your utter_ask_<form_name>_<slot_name> in the domain. This way, Rasa will pick a different response each time. Chances are that some users might see the same boring response multiple times until they provide the correct information that passes the slot validation.
  2. Create a custom action_ask_<form_name>_<slot_name> . This will be triggered if no utter_ask_<form_name>_<slot_name> or utter_ask_<slot_name> are found, so make sure to remove them. In this action, you could take a look back at the previous response and choose a different one to avoid repetition, or even prompt the user to provide this missing information in a totally different way.

Hello snek,

Thanks for your response, however my question deviates from wat you have answered. My concern is more towards the multiple utters done by bot. If you look at the output image i have uploaded it is repeating the utter message multiple times. for example: if i say “hello” in the chat

bot responds with

hello what can i do for you?

hello what can i do for you?

hello what can i do for you?

however i need this “hello what can i do for you?” message just once.

Thanks in advance

Sorry for the misunderstanding, I thought you meant that it’s always the same message being repeated when you said this, my bad. I can’t spot anything particularly incorrect in your rules or action classes and methods. What do you get when turning debugging mode on in rasa?