Rasa sending more than one message in response json for form answer rasa x

I am using rasa x. And access rasa using nodejs APIs.

I have to fill a form so shows list of cities to choose, User has to select a number assigned to each city. This is how i have written an action

class CityRequirementForm(FormAction):
    def name(self):
        return "city_form"

    @staticmethod
    def required_slots(tracker: Tracker):
        return ["area"]

    def slot_mappings(self):
        return {
            "area": self.from_text()
        }
    # method to validate the user entered information in the slot
    def validate_retailer(
            self,
            value,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain):
        
        # extract the store lists from the slot
        area_list = tracker.get_slot('area_list')

        try:
            if isinstance(int(value),int):
                if int(value) > len(retailer_detail_list):
                    dispatcher.utter_message(template='utter_invalid_area')
                    return {'area': None}
                else:
                    return {'area': value}
        
        except Exception as err:
            dispatcher.utter_message(template='utter_invalid_area')
            return {'area': None}

I return the area as None of user does not select the number from the given list or type something else.

This works on Rasa X ui perfectly. If I check the response of rasa in network tab, there are list of 2 messages. First one is actual message utter_invalid_area and second is the slot message that form is realted with (“Choose the city… list of cities”).

In NOdejs Apis I am appending the responses for a certain reason, but in this case second message is use less to me,

Is there any way to trim the second message? Or any other approach to achieve the same?

In NOdejs Apis I am appending the responses for a certain reason, but in this case second message is use less to me,

Not sure what this means. Are you saying using identical code, the behaviour in your Nodejs API is different from Rasa X, or that you would like it to be and it isn’t?

rasa sends 2 message object as response. One(0th element) that I uttered in the action and the second is the question itself (previous message that was asked to fill the form with list of options).

I need only the uttered message in the response. All i want is to remove the second message from the response json

This depends how these messages are getting sent. Are you using the default request_next_slot method? If so, that second message is the form prompting for the next slot. If you want to modify that behaviour, overwrite the request_next_slot method.

It will be easier to understand what you’re going for with concrete examples.

i have posted the action code, i am uttering the utter_invalid_area template response if the user input value does not match the requirements (integer number it should be)

the json response

[

  1. utter_invalid_area,
  2. response for the slot itself (list of options) ]

all i need is either to delete the second message or to update the response text.

If you don’t want it to keep asking for the slot, you need to deactivate the form as part of the validation action.