Usert enter random message and continue with predifined utter

Hi friends,

I have a conversation where i ask user “what you did during Christmas?” with utter utter_ask_question and next the user should enter an answer that should be always intent random_answer, does not matter what the content of the message is.

Story would look like this:

  • hi
  • utter_hi
  • utter_ask_question
  • random_answer
  • utter_thanks

The idea is that regarding the random text the user enter, it has to be recognized as random_answer and it should follow with utter_thanks

I did some tests with forms but not luck so far


I did this FormAction

class FormRandom(FormAction):
      def name(self) -> Text:
         """Unique identifier of the form"""

         return "form_random01"
      def required_slots(tracker: Tracker) -> List[Text]:
         """A list of required slots that the form has to fill"""

         return ["random_answer"]
      def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:

         return {
              "random_answer": [self.from_entity(entity="random_answer"), self.from_text()],

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

But for my use case, it would be a pain, create a action for everytime I have the need to specify random input.

There is a better way to address this need?

I didn’t got your question. Can you rephrase it in more elaborated form?

Hi Bhanu,

we have in the conversation different paths where we ask to our users an open question, let say we have around 20 cases where we ask such questions. There the user will answer any random text, and the idea is that after we receive the message we do not predict anything but we continue with the path as it is define in the story. When we make this open question, normally there is just one path, then we would like the conversation to flow to the next intent, instead to guess/predict the message in specific.

So far what I did is to create a FormAction for every single random answer in the story, but it does not look so good, though it is working.

I would like to know from our community if there is a better way to address this use case.

All the best

Hey @alebeta90,

According to rasa docs, if your NLU model picks up an entity, and your domain contains a slot with the same name, the slot will be set automatically. For example:


  • greet{“name”: “Ali”}
    • slot{“name”: “Ali”}
    • utter_greet

In this case, you don’t have to include the - slot{} part in the story, because it is automatically picked up.

To disable this behavior for a particular slot, you can set the auto_fill attribute to False in the domain file:

slots: name: type:text auto_fill: False

So in same manner you can mark all the text inside training data (for intent=random_answer) as entity (= random_answer). In this way all the text inside random_answer intent will also be detected as entity and can be used to update the slot.

But in my view using forms is better if you want to scale your bot by adding other intents and entities.

Hi Bhanu,

Thanks for the answer,

in this case, creating training data would be a quite challenging because the answer of the user can be anything, then it would be never enough training data to satisfied the requirement or the training data can get confuse with different kind of answer.

This is why so far, Form Actions are a good way to go, but in my own opinion seems to be a lot of work for that.

All the best

If you want to respond to anything the user says with an utter_thanks, then using forms is the way to go. But I think your problem is that you’re trying to fill the required_slot with self.from entities. In this case you can also do self.from_intent(intent=“random_answer”), but of course how can you get enough training data to match anything into random_answer? So the right way to go is to use self.from_text() to fill the required slot. That will match anything the user will say. You already do that. Then in the “submit” you do this: return [FollowupAction('utter_thanks")]

So your form will ask the user a question, get any answer and finish with “utter_thanks”.

I think that should work.