Extract entity from last entered user input text

is it possible to extract entity from the last user input text and only from that last input text? I am looking for a method similar to tracker.get_latest_entity_values("PERSON"), instead of extracting latest entity value of the entity “Person”, I want to extract entity person is present in the last user input text.

use case: A form that is used to collect personal details (slots: name, phone_number, etc). After filling the slot person_name (filled by entity extraction) the user might request to change his name. If the user input contains entity PERSON ("Can i change my name to Adam Jon") I need to update the old slot person_name with the entity value of PERSON and if the user text doesn’t have the Entity PERSON ("Can I change my name?"')I need to update the slot value with None`

tracker.latest_message is a dictionary containing the attributes of the latest message: intent, entities, and text.

So try tracker.latest_message['entities'] and see if it has the entity PERSON.

1 Like

Thank You @ChrisRahme this works well

1 Like

is there a simple method something like next(tracker.get_latest_entity_values('entity_type'), None) that gives us all the values of an entity from last user input

eg : what is the price and color of the car? here price and color are of same entity ‘car_attribute’, If I use next(tracker.get_latest_entity_values('entity_type'), None) i will get only one value .

I know i can loop through tracker.latest_message['entities'] to resolve me issue, I am looking for simple method, If someone knows it please let me know

tracker.latest_message['entities'] should contain all entities in your message