Rasa form extract entity when only entity is provided


I have a form which extract two locations, and it works fine if the user provide some context. For example if the bot asks ‘Where do you need to go’, the user can answer 'i need to got to Finland and it works fine, however it does not work if the user only answers ‘Finland’. Since we can’t tell the to location-slots apart. How would i go about to solve this?


Hi :wink:

Are you using a Form Action to extract this information ?

What do you mean by :

Since we can’t tell the to location-slots apart.

For the moment, I see 2 options :

  • Add more NLU data with only entities to train the extractor to work better.
  • Use a pre-trained NER like Spacy to extract such entities like countries.

What i mean by:

Since we can’t tell the to location-slots apart.

Is that the slots could potentially contain the same data and since the Form doesn’t always fills the requested slot, but the one that matches the best I don’t think it helps to provide it more data. And i have thought about Spacy but I don’t only want to extract locations in this manor but other kind of entities.

For example in a restaurant form bot the bot might ask ‘what type of food do you want’ to fill the ‘food_type’ slot. But the user can answer ‘i want to eat at 5pm’ and instead of filling ‘food_type’ we fill the slot ‘eating_time’

Yes, because in a restaurant bot you require both “food_type” and “eating time”. So if the user provide an answer that contain these slots RASA will automatically fill them and re-ask the question about the food_type if the slot is none (correct me if I’m wrong).

If you use forms, RASA will automatically fill the slots that are required. In this case, it doesn’t matter what the intent is, the real info is in the entities.

For example, if I try to make bot restaurant. I will create a form to ask required information (food_type, eating_time, location, etc.). This form will be triggered by the intent i_want_to_eat in stories. In the form RASA will ask the questions automatically until all the slots are filled (without looking in the intents) with entities.

Yes I’m aware of this but because of this it is hard to extract to slots in a form that are very simular. Say I have to slots to fill in a form, to_location and from_location. If the user tells the bot ‘Finland’ when the bot is requesting one of the slot how can the bot determin which slot to fill with ‘Finland’, to_location or from_location because could be correct.

I agree. This is a more complicated case in fact.

I got similar issues. In my company we called that “complex entities” such as dates, durations, etc. Location is the same thing.

The way we handle them is pretty simple. We use a buffer slot. Assuming all the locations are location in the NLU. If we need to detect from_loc and to_loc we decide which one need to be populated in the validate function.

if requested_slot == "form_loc" and tracker.get_slot('location') is not None : 
     slots_values["form_loc"] == tracker.get_slot('location')
elif requested_slot == "to_loc" and tracker.get_slot('location') is not None : 
     slots_values["to_loc"] == tracker.get_slot('location') 

I don’t know if this is a good practice but it works for me :slight_smile:

Aha okay thank you! I was thinking of something similar. I was thinking of only extraction a location slot and on depending on which slot is requested i put the location-slot data in the requested slot. I will try to implement this, thanks for all the help!

1 Like

Let me know if it’s working for you :wink: