Free-text / random-text to fill slots

Hi there. Here’s my scenario:

i am building a bot whose major function is to send emails. Now the email body can contain any type of texts and messages. My bot asks the user for a message to be sent, which is eventually stored in a slot. Apparantly, it can’t be done. The slot is only being set from what is stored in the respective intent. else it will be set with “None”. Is there any way to fill this slot with a free (any) text without defining intents for it? @akelad @Juste

I am facing the same general problem, Aayush. In my case, I am trying to use NLU to direct activity on the computer. For instance I would have liked to have isssued the utterances:

Click on the message from aauysh. Click on the Reply button. Type ${all_this_text} into the message box. Click on the Reply button.

Just being an example, I’d like to generalize from there and have Rasa recognize the free-text. But, it seems that Rasa is focused on searching out words that it can categorize as entities, and then passing them in a structure with an intent.

I’m only a couple weeks into this, but it feels to me that the entity classification approach has limited usefulness outside of a very constrained context.

1 Like

If I understand correctly what you are looking for is this

1 Like

@Zylatis The discussion there is to collect user response without extracting the entities (But it uses intent that is trained by nlu)

What I am looking for is to extract user response without relating it to any intent (as a free text) . i.e. my bot need not “understand” what a user is saying… it just need to set any kind of response to the slot.

Okay then I’m not sure I understand your query. The method given there allows one to extract user input at a given point in a story no matter the intent, assuming one has gotten to that point in the story which is of course intent based.

I have used this, for example, when asking for a reference number during a modify_booking intent question. Rather than write a whole form, you can have

  • utter_ask_ref
  • action_listen
  • action_get_ref

This action_get_ref simply takes whatever the response the user gives during action_listen and shoves it in a slot which is parsed later on, is this not what you are asking about? I am assuming you are using Core here and so to get anywhere with Core you will of course need intents and so on otherwise the stories don’t make much sense.

Did that make sense/help?

1 Like

I believe you have to use custom actions to do that. A while back I did something similar. But to trigger the action, the bot needs to identify that it belongs to a particular intent only then it will work.

Define a slot as unfeaturized. Then whenever that intent is identified, go to your custom actions do something like this:

class Actionform_2(Action):
   def name(self):
       return "form_2"

   def run(self, dispatcher, tracker, domain):
       message = tracker.latest_message.get('text')
       return [SlotSet('email', message)] #slot value can only be set by returning it

@Zylatis that make sense and thats exactly what i am looking for (in case you don’t have any specifed format for the reference number, for eg. same length digits) (would your bot also accept a text instead of a number?)

I am trying to use action_listen and currently working on it. But its causing some errors and unexpected behaviours.

User input from action_listen is not being set in the slot and the story is not being followed.

The specific portion of my story goes like this:

* inform{"date": "2019-04-19"}
  - action_end_date
  - slot{"to": "2019-04-19"}
  - utter_ask_reason 
  - action_listen #user inputs any random reason that may not be in the intent
  - action_ask_reason #to set the slot
  - utter_confirmation

The action is written as:

class AskReason(Action):
	def name(self):
		return 'action_ask_reason'

	def run(self, dispatcher, tracker, domain):
		personal = tracker.latest_message.get('text')
		return [SlotSet('reason',personal)]

Inform intent contains only sample date and time formats which i need:

## intent:inform
- [2019-04-16](date)
- [2019-04-19](date)
- [2019-04-20](date)
- [09:30:00](time)
- [10:00:00](time)

I did not make an intent for the “reason” because if i had made one , the slot will only be set if my reason fell under the respective intent.

since i am new to RASA, please feel free to suggest anything that could be missing here :slight_smile:

@srikar_1996 Agreed, and that is pretty much the action I use, though without the utter part, as i put that in the story. I also think this may lead to problems if you don’t have the name with ‘action_’ prefix as @aayush has.

Regarding your point @aayush I’m not entirely sure. I also encountered an issue with the slot filling from NLU but I don’t think that would be the problem here. However we can test it: what happens if you remove the specific date from the inform intent part of the story. For now just make it so that the inform intent leads to ask_reason, then listen, then the custom action. One thing that has caught me out a few times already is making sure the slots and actions are actually listed in the domain.yml. It seems to correctly throw errors in training if actions are missing but not always entities/slots.

EDIT: the issue to which I am referring is open here if interested

It remains unclear if it is a Rasa issue or just something I was doing wrong - out of interest, is your slot ‘to’ being set properly?

@Zylatis yes the “to” slot is being set correctly and i have made my storyline (mentioned above) so that the intent ‘inform’ leads to ask_reason, then listen and then the custom action. It all goes perfect until action_listen. But the problem starts with action_ask_reason (the action to set the slot)

When i run my bot in interactive mode, i get an input section in the action_listen (as expected). And whenever a text (reason) is entered, it asks ‘what intent do my reason fall on?’.

Well thats the problem because i don’t have an intent for it (or is it really necessary to have an intent? in which case i will have to enter a reason present in that particular intent) .My bot is supposed to set the slot with whatever i have entered in my action_listen

@aayush the core automatically expects the text after action_listen to belong to a particular intent because it needs to identify that to perform the next action. That’s the reason it’s not working the way you expect.

@Zylatis is this working fine for you? I guess you’d be facing the same issue as Aayush?

@srikar_1996 Now i understand that. i will have to create an intent whatever be the case.

@zylatis probably had defined the reference number as the entity value of fixed length. In which case it works like a charm.

I shall define an intent for the ‘reason’ that the user enters, with few examples. But i wonder if i can set my input to a slot by defining the slot as ‘unfeaturized’. Did it really work for you Srikar? because a text different from the intent examples can be input by the user

Since you’re going to use an intent, you can use the text slot as well. But the unfeaturized slot should also work, it just means the slot value won’t affect the dialogue flow.

@srikar_1996 apparantly i am not able to extract ‘any text’ entered by the user. The slot is only being set for those inputs that has been defined in the intent and trained.

You’re using custom actions right? If you set the slot in there, you should be able to fill the slot with the text.

@srikar_1996 here’s my custom action. The slot gets filled, but only with the texts defined under days_off_reason intent. I am actually searching for a feature equivalent to @sys.any in dialogflow. The only thing i can do now is to make a lot of training data and train the nlu.

@aayush It will fill obviously fill the text which was identified under the days_off_reason because that’s what triggered the action_get_reason right.

This definitely needs to be done or else it might go into default_fallback.

1 Like