Capturing free text in forms

Hi. I am developing a dialog with multiple entities and intents. I wanted to add a form to record user satisfaction comments, but I can’t find a way to capture free text. I have modified the slot_mapping function and using self.from_text () but it always recognizes some previous entity or intention. The tracker.latest_message.get (‘text’) function did not work for the same reason either. I use RASA 1.8. Is it appropriate to add some intentent / inform for the free text? ad hoc? Is there a way to solve it?

Hello @ClaudioSpinelli,

The slot mapping self.from_text() is what you normally use to extract free text in user’s message, so you are doing it the right way. Are there any other slot mappings for that particular slot ? If it’s possible, please post your slot mapping function.

def slot_mapping(self) -> Dict[Text, Union[Dict,List[Dict]]]:

    return {"comment": [self.from_text()]}

the problem is that there are multiple intentions and entities, and the policies always recover some of them and the text are passed as different intents or entities to the current one and in fact this action never gets to be executed. The code has other extra forms, but that is not the problem,

i mean, the problem is in the NLU area, when recognizing the intent and the entity

@ClaudioSpinelli

Sorry for late response.

I’ve never encountered this issue using self.from_text(). I have even seen it extracts rasa command messages like /inform{"slot_name": "value"} as free text correctly. If the slot which is being asked is indeed the comment slot, there shouldn’t be any problem for the NLU to pick up whatever the user message is as free text.

Also, the function is slot_mappings(self) not slot_mapping(self), so if that is not a typo in your post maybe give that a try. Otherwise i might need to see the the logs, your domain and action file to investigate further.

in actions.py ->>>>>

class comentarioForm(FormAction): import logging import typing from typing import Dict, Text, Any, List, Union, Optional, Tuple

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

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

def slot_mapping(self) -> Dict[Text, Union[Dict,List[Dict]]]:

    return {"comentario": [self.from_text()]}    

def submit(self, dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:  

    nombre = tracker.get_slot('nombre_usuario')
    apellido = tracker.get_slot('apellido_usuario')
    texto = tracker.get_slot('comentario')
    save_comentario(nombre,apellido,texto)

in domain.yml ->>>>> slots: comentario: type: unfeaturized auto_fill: false

forms:

  • formulario_comentario

in NLU.md–>

nothing

the form is triggered in base of the stories

perhaps auto_fill: false is inconvenient?

@ClaudioSpinelli

I remember that auto_fill: false do mess with slot filling sometimes. So try auto_fill: true to see how it goes.

Again, the function is slot_mappings(self), you are missing an “s” at the end, so fix that as well.

It worked. It was the missing “s”. I had copied it from a poorly written post Slot_mapping

Thanks Huy