# How can I access metadata in custom actions?

**URL:** <https://forum.rasa.com/t/how-can-i-access-metadata-in-custom-actions/46716>\
**Category:** Rasa Open Source\
**Created:** [August 10, 2021, 6:42am UTC](https://forum.rasa.com/t/how-can-i-access-metadata-in-custom-actions/46716 "2021-08-10T06:42:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnkitChouhan](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@AnkitChouhan](https://forum.rasa.com/u/AnkitChouhan)\
**Post date:** [August 10, 2021, 6:42am UTC](https://forum.rasa.com/t/how-can-i-access-metadata-in-custom-actions/46716/1 "2021-08-10T06:42:40Z")

</div>

nlu:

- intent: secured\_isolated

I need to access this metadata “ask” in custom action. How do I do that?

---

<div class="post-metadata">

**Author:** ![krkc](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@krkc](https://forum.rasa.com/u/krkc)\
**Post date:** [August 10, 2021, 8:50am UTC](https://forum.rasa.com/t/how-can-i-access-metadata-in-custom-actions/46716/2 "2021-08-10T08:50:04Z")

</div>

Hey @AnkitChouhan

I think you intention was to read the metadata in your action python. If yes, here is some sample code which you can refer…

> ```
> > class ActionSearchResult(Action):
> > def name(self):
> > return "action_result"
> > 		
> > def run(self, dispatcher, tracker, domain):
> > item = tracker.get_slot('item')
> > item = item.lower()
> > 		
> > 		
> > if item =="book":
> > dispatcher.utter_message("Hello from books...!")
> > elif item =="course":
> > dispatcher.utter_message("Hello from courses...!")
> > elif item =="skill":
> > dispatcher.utter_message("Hello From Skills...")
> 
> ```

Further, you have to register the entity like, from the above code the entity is **“item”** in your domain.yml

```
> entities:
> - item
> slots:
> item:
> type: text
> influence_conversation: true

```

Also, you have to pass these entities from the nlu intents.

```
- intent: ask_query
        examples: |
- i'm looking for important [books](item:book) in machine learning 
- [ML Books](item:book)
- [ML Courses](item:course)
- [Machine Learning Courses](item:course)
- [ML Skills](item:skill)

```

and map the corresponding slots in your stories. Thanks

stories:

- story: happy path1 steps:

- story: happy path2 steps:

- story: happy path3 steps:

Best Regards, Ravi

---

<div class="post-metadata">

**Author:** ![AnkitChouhan](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@AnkitChouhan](https://forum.rasa.com/u/AnkitChouhan)\
**Post date:** [August 11, 2021, 5:16am UTC](https://forum.rasa.com/t/how-can-i-access-metadata-in-custom-actions/46716/3 "2021-08-11T05:16:50Z")

</div>

Thanks for the quick reply. But I wanted to fetch the metadata not the entities(or slots) from user messages.

 ![Screenshot (142)](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/9/2/92ed44a33fc140860407c28f453f537136a97105.png) . This is the screenshot from rasa documentation, I want to implement such kind of feature and fetch “sentiment”:“neutral” (according to the screenshot) in my custom actions.py file

---

<div class="post-metadata">

**Author:** ![gerrycheung](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@gerrycheung](https://forum.rasa.com/u/gerrycheung)\
**Post date:** [March 19, 2022, 2:20am UTC](https://forum.rasa.com/t/how-can-i-access-metadata-in-custom-actions/46716/4 "2022-03-19T02:20:13Z")

</div>

@AnkitChouhan Did find solution?
