# Extract entity from last entered user input text

**URL:** <https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801>\
**Category:** Rasa Open Source\
**Created:** [August 12, 2021, 10:24am UTC](https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801 "2021-08-12T10:24:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![athulvingt](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/athulvingt/32/16181_2.png) [@athulvingt](https://forum.rasa.com/u/athulvingt)\
**Post date:** [August 12, 2021, 10:24am UTC](https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801/1 "2021-08-12T10:24:52Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [August 12, 2021, 11:10am UTC](https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801/2 "2021-08-12T11:10:47Z")

</div>

`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`.

---

<div class="post-metadata">

**Author:** ![athulvingt](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/athulvingt/32/16181_2.png) [@athulvingt](https://forum.rasa.com/u/athulvingt)\
**Post date:** [August 13, 2021, 4:51am UTC](https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801/3 "2021-08-13T04:51:50Z")

</div>

Thank You @ChrisRahme this works well

---

<div class="post-metadata">

**Author:** ![athulvingt](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/athulvingt/32/16181_2.png) [@athulvingt](https://forum.rasa.com/u/athulvingt)\
**Post date:** [October 5, 2021, 1:14pm UTC](https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801/5 "2021-10-05T13:14:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [October 5, 2021, 3:44pm UTC](https://forum.rasa.com/t/extract-entity-from-last-entered-user-input-text/46801/6 "2021-10-05T15:44:45Z")

</div>

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