Multiple roles of a single entity problem

I want to extract few slots from the message named as from_date, to_date , and review cycle through custom actions. But due to same date format, my model is taking to_date also as from_date …to solve that I made dates as different entity and defined two roles as from_date and to _date…and kept my actions.py as same but it is not extracting the slots as expected. my nlu.yml is - intent: check_employee_goals examples: |

  • Give me goals of the company from [2024-01-01]{“entity”: “dates”,“role”:“from_date”} to [2024-03-31]{“entity”: “dates”,“role”:“to_date”} with review cycle in FY23-24
  • From the date [2023-05-30]{“entity”: “dates”,“role”:“from_date”} to [2023-11-23]{“entity”: “dates”,“role”:“to_date”} with review cycle in FY22-23, give me goals and my domain.yml is slots: employee_id: type: text mappings: # Added the missing ‘mappings’ key and value
  • type: from_entity entity: employee_id

from_date: type: text mappings:

  • type: from_entity entity: dates role: from_date

to_date: type: text mappings:

  • type: from_entity entity: dates role: to_date

review_cycle: type: text mappings:

  • type: from_entity entity: review_cycle and in my actions.py it is extracted as def name(self) → Text: return “action_check_employee_goals”

def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) → List[Dict[Text, Any]]:

from_date = tracker.get_slot(“from_date”) to_date = tracker.get_slot(“to_date”) review_cycle = tracker.get_slot(“review_cycle”) . Can anyone trace the issue into these codes, why from_date is taking the slot of to_date and how can it be fixed?

Hello,

NLU Training Data - Rasa: This is the official documentation of Rasa NLU training data format, where you can learn how to define entities, roles, and groups in your NLU data. You can also find some examples of how to use roles and groups for different scenarios, such as restaurant orders or travel bookings.

How can I extract entity role, entity group from slot: This is a forum post where a user asked a similar question to yours, and another user provided a solution using the tracker.get_latest_entity_values method. You can try to adapt this method to your use case and see if it works.

Custom Slot Set in NLU/Custom NLU Component: This is another forum post where a user asked how to set a custom slot in NLU, and a moderator suggested using a custom NLU component that does entity extraction and then configures a slot to automatically be filled with the entity. You can check out the Rasa NLU Examples repository for some examples of custom NLU components.

Train the RASA NLU to extract the entities and fill slot based on regular expressions: This is yet another forum post where a user asked how to use regular expressions to extract entities and fill slots, and a moderator provided some code snippets and links to the documentation. You can use regular expressions to define more specific patterns for your date entities, and make sure they match the format you expect.

I hope these resources are helpful for you.

Best regards,

Latonya Dodson