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