# Get the name value into the actions.py

**URL:** <https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098>\
**Category:** Rasa Open Source\
**Created:** [March 17, 2019, 9:53am UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098 "2019-03-17T09:53:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![M1ns](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/m1ns/32/2183_2.png) [@M1ns](https://forum.rasa.com/u/M1ns)\
**Post date:** [March 17, 2019, 9:53am UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/1 "2019-03-17T09:53:29Z")

</div>

Hey there, How can I get from the rasa stack starterpack the value of the name example into the actions.py file? So I want to make a WeatherAction and when I say: “Tell me the current weather in London”, that he take the value “London” into the actions.py file.

best regards norman

---

<div class="post-metadata">

**Author:** ![netcarver](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/netcarver/32/1147_2.png) [@netcarver](https://forum.rasa.com/u/netcarver)\
**Post date:** [March 17, 2019, 4:07pm UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/2 "2019-03-17T16:07:46Z")

</div>

Hi Norman,

You can use the `get_latest_entity_values()` method from the tracker to access the value(s) of a given entity from within your action’s `run()` method.

If you are using a spaCy pre-trained model, it handily pulls locations out into a GPE entity for you so you could do something like this…

```
class ActionWeather(Action):

    def name(self):
        return "action_weather"

    def run(self, dispatcher, tracker, domain):
        where = next(tracker.get_latest_entity_values('GPE'), None)
        if where is not None:
            dispatcher.utter_message("You asked about {}".format(where))
        else:
            dispatcher.utter_message("I couldn't tell where!")
        
        return []

```

Hope that helps!

---

<div class="post-metadata">

**Author:** ![M1ns](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/m1ns/32/2183_2.png) [@M1ns](https://forum.rasa.com/u/M1ns)\
**Post date:** [March 17, 2019, 5:36pm UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/3 "2019-03-17T17:36:32Z")

</div>

I made it like you now, but he always say “I couldn’t tell where”. But I wrote also the city! That is my weather intent.

## intent:weather

- Tell me the weather in Berlin
- What is the weather in California?
- Say what in Moskau is the weather
- Hamburg is the weather?

---

<div class="post-metadata">

**Author:** ![netcarver](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/netcarver/32/1147_2.png) [@netcarver](https://forum.rasa.com/u/netcarver)\
**Post date:** [March 17, 2019, 5:40pm UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/4 "2019-03-17T17:40:56Z")

</div>

Ok, so that shows that the action server is working but you’ll need more training data to get the NLU reliably picking up the location entity. I suggest you add at least 20 more training examples and then re-train the NLU.

---

<div class="post-metadata">

**Author:** ![M1ns](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/m1ns/32/2183_2.png) [@M1ns](https://forum.rasa.com/u/M1ns)\
**Post date:** [March 18, 2019, 8:41am UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/5 "2019-03-18T08:41:47Z")

</div>

I have now 24 samples and my chatbot say just, that he dont know where. Dont know what I did wrong there

---

<div class="post-metadata">

**Author:** ![netcarver](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/netcarver/32/1147_2.png) [@netcarver](https://forum.rasa.com/u/netcarver)\
**Post date:** [March 18, 2019, 10:13am UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/6 "2019-03-18T10:13:29Z")

</div>

> [@netcarver](#):
>
> If you are using a spaCy pre-trained model, it handily pulls locations out into a GPE entity

Are you using the Spacy pipeline, or something else?

Can you post a sample of your training data - it may be you are using a different entity name.

---

<div class="post-metadata">

**Author:** ![M1ns](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/m1ns/32/2183_2.png) [@M1ns](https://forum.rasa.com/u/M1ns)\
**Post date:** [March 18, 2019, 3:27pm UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/7 "2019-03-18T15:27:16Z")

</div>

I use the spacy\_sklearn pipeline and my sample of my weather intent in nlu\_data.md is:

## intent:weather

- Tell me the weather in [Berlin] (weather)

- What is the weather in [California] (weather)?

- Say what in [Moskau] (weather) is the weather

- [Hamburg] (weather) is the weather?

- Tell me the temperature of [Bengasi] (weather)

- Is in [Geldern] (weather) nice weather?

- Tell me, what temperature is now in [Sachsen] (weather)

- Is now a nice weather in [London] (weather) to make holidays?

- What about [Johannesburg] (weather), is there a nice weather?

- Is the temperature in [Hannover] (weather) high?

- Is the temperature in [Straelen] (weather) low?

- Is it cold in [Krefeld] (weather)?

- Can you tell me, is it hot in [Florida] (weather) at the moment?

- Can you tell me, is it hot in [Bengasi] (weather) at the moment?

- Can you tell me, is it hot in [Mainz] (weather) at the moment?

- Is now a nice weather in [Britain] (weather) to make holidays?

- What about [Luxenburg] (weather), is there a nice weather?

- Tell me the weather in [Orlando] (weather)

- What is the weather in [Barcelona] (weather)?

- Say what in [Canada] (weather) is the weather

- [Bermuda] (weather) is the weather?

- Is the temperature in [Panama] (weather) high?

- Is the temperature in [Cuba] (weather) low?

stories.md:

## story\_weather

- weather

- action\_weather

The action\_weather is the same like what you wrote

---

<div class="post-metadata">

**Author:** ![netcarver](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/netcarver/32/1147_2.png) [@netcarver](https://forum.rasa.com/u/netcarver)\
**Post date:** [March 18, 2019, 7:03pm UTC](https://forum.rasa.com/t/get-the-name-value-into-the-actions-py/6098/8 "2019-03-18T19:03:53Z")

</div>

In your training data, you have called the entity “weather”, but the action.py code is expecting it to be called “GPE”. Just changing the run method in the action.py code to read…

```
where = next(tracker.get_latest_entity_values('weather'), None)

```

…should fix that.

There’s documentation for the NLU [markdown format here](https://rasa.com/docs/nlu/dataformat/#markdown-format).

Personally, I find having the same name for the intent and the entity rather confusing. It’ is clearer if the entity is named after what it really represents. I think your training data is confusing as it is marking up the location (the city/place) and calling it “weather.”
