Entity detection problem

Hey guys I need a solution as soon as possible: During the slot filling part, I want to fill Melbourne to source_airport slot, which extracts city entity from User message. However when the city entity is detected,it fills another slot called city for a different action. I want Melbourne to detect source_airport and destination_airport instead. I still didnt understand how to use same entity for different intents and different slots and this has been really frustrating for the past 2 weeks. Here are some screenshots:

1)Chat question:

2)Initial Entity detection:

3)Slot filled as city.

4)I am forced to do this manually.

5)Outcome needed:

I don’t think rasa has a native solution for this. The easiest solution I can think of would be to write a custom action that copies the value of city to source_airport.

Something like this(untested) should work:

from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet

class SourceAirportAction(Action):
   def name(self):
      # type: () -> Text
      return "source_airport_action"

   def run(self, dispatcher, tracker, domain):
      city = tracker.get_slot('city')
      return [SlotSet("source_airport", city)]

Just add this action after the city slot is filled by the inform_city intent and add an equivalent action for destination_airport.

1 Like

I should’ve mentioned I have destination_airport as well immediately after source_airport. I have been following the same procedure you have mentioned with and all 3 of my slots and entities are named the same: source_airport, destination_airport, and city The problem is that the bot gets confused while detecting which entity the value belongs to, Hence I discarded the idea of having source_airport and destination_airport as entities and just stick to one entity called city that can feed data to 3 slots available,