# Get data as slots from logged in users

**URL:** <https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173>\
**Category:** Rasa Open Source\
**Created:** [March 11, 2021, 7:11pm UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173 "2021-03-11T19:11:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ridasaleem0](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ridasaleem0](https://forum.rasa.com/u/ridasaleem0)\
**Post date:** [March 11, 2021, 7:11pm UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/1 "2021-03-11T19:11:17Z")

</div>

Hey so I think I am running into a conceptual issue here, I want to fill certain slot values with currently logged in user’s details by fetching them through my database. I am not sure will I be using sender\_id to match with database’s uid or what?

How can we use sender\_id to fetch details of currently logged-in user? What actually is sender\_id? @erohmensing

---

<div class="post-metadata">

**Author:** ![mloubser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mloubser/32/13021_2.png) [@mloubser](https://forum.rasa.com/u/mloubser)\
**Post date:** [March 12, 2021, 10:04pm UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/2 "2021-03-12T22:04:21Z")

</div>

Unless your channel manages it, the sender\_id is generated automatically by rasa and is unique per convo session. For example, the Slack connector uses the `user` event to set the sender\_id:

> <https://github.com/RasaHQ/rasa/blob/ccad4707280e73475c5d85348a48bb22ae1b3c90/rasa/core/channels/slack.py#L510>

---

<div class="post-metadata">

**Author:** ![ridasaleem0](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ridasaleem0](https://forum.rasa.com/u/ridasaleem0)\
**Post date:** [March 15, 2021, 4:47am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/3 "2021-03-15T04:47:47Z")

</div>

okay sounds about right. But should I be making an api call to my app/website or what exactly? could you please maybe provide an instance?

---

<div class="post-metadata">

**Author:** ![mloubser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mloubser/32/13021_2.png) [@mloubser](https://forum.rasa.com/u/mloubser)\
**Post date:** [March 15, 2021, 7:37am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/4 "2021-03-15T07:37:05Z")

</div>

You can take a look at these docs: [Custom Connectors](https://rasa.com/docs/rasa/connectors/custom-connectors) On implementing a custom connector, they tell you the required methods.

It’s actually your channel (so website/app) that will be making API calls to Rasa. So, once you have defined your custom connector, you put Rasa’s webhook address in the right place in your app/website. If you look at the Slack example, or the Rest example, you’ll see that pattern in both cases.

---

<div class="post-metadata">

**Author:** ![ridasaleem0](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ridasaleem0](https://forum.rasa.com/u/ridasaleem0)\
**Post date:** [March 15, 2021, 11:35am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/5 "2021-03-15T11:35:03Z")

</div>

okay. I am a little confused here. I want to greet my logged-in user with his/her name by querying through database or probably using an api? Can you suggest me the most elegant way to achieve it?

---

<div class="post-metadata">

**Author:** ![ridasaleem0](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ridasaleem0](https://forum.rasa.com/u/ridasaleem0)\
**Post date:** [March 15, 2021, 11:36am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/6 "2021-03-15T11:36:57Z")

</div>

I went through a bunch of forum posts but couldn’t find a step by step procedure for achieving it. And the possible ways that rasa provides

---

<div class="post-metadata">

**Author:** ![mloubser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mloubser/32/13021_2.png) [@mloubser](https://forum.rasa.com/u/mloubser)\
**Post date:** [March 16, 2021, 10:51am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/7 "2021-03-16T10:51:21Z")

</div>

In that case, all you want is a custom action. [Actions](https://rasa.com/docs/action-server/sdk-actions) A custom action can do whatever you program it to do, including querying a database. Possibly you haven’t found what you’re looking for because you’ve been looking at channels, when really you want a custom action. If you, in addition to that, want the `sender_id` to match that name, that’s when you need to look at the channel side of things.

---

<div class="post-metadata">

**Author:** ![mloubser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mloubser/32/13021_2.png) [@mloubser](https://forum.rasa.com/u/mloubser)\
**Post date:** [March 16, 2021, 10:53am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/8 "2021-03-16T10:53:36Z")

</div>

You’ll find plenty of examples on the forum about custom actions, or you can look at these demo bots’ action code:

> <https://github.com/RasaHQ/financial-demo/blob/master/actions/actions.py>

> <https://github.com/RasaHQ/helpdesk-assistant/blob/main/actions/actions.py>

Here’s one with a customized greeting action that takes name into account (among other things):

> <https://github.com/RasaHQ/rasa-demo/blob/1763eaf77b23f74497bd5f5ab8914edcf430f011/actions/actions.py#L384-L421>

---

<div class="post-metadata">

**Author:** ![ridasaleem0](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ridasaleem0](https://forum.rasa.com/u/ridasaleem0)\
**Post date:** [March 16, 2021, 11:38am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/9 "2021-03-16T11:38:07Z")

</div>

Okay great. I am querying a database and using postman to test the sender\_id to match my logged-in user’s id. Now what I need to discover is that can I make my app/website send current logged-in user’s id as sender\_id when using (tracker.current\_state())[“sender\_id”] inside my custom action?

---

<div class="post-metadata">

**Author:** ![ridasaleem0](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ridasaleem0](https://forum.rasa.com/u/ridasaleem0)\
**Post date:** [March 16, 2021, 11:40am UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/10 "2021-03-16T11:40:11Z")

</div>

great help, thankyou so much.

---

<div class="post-metadata">

**Author:** ![mloubser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mloubser/32/13021_2.png) [@mloubser](https://forum.rasa.com/u/mloubser)\
**Post date:** [March 16, 2021, 2:05pm UTC](https://forum.rasa.com/t/get-data-as-slots-from-logged-in-users/41173/11 "2021-03-16T14:05:12Z")

</div>

> can I make my app/website send current logged-in user’s id as sender\_id when using (tracker.current\_state())[“sender\_id”] inside my custom action?

You cannot “change” the sender\_id inside a custom action, you can only access it. If you want to **set** the sender ID, that needs to happen on the channel side.

Since you are using Postman, I’m assuming you are calling the Rest webhook. In this case, you would use the intended sender\_id in the payload you send to the webhook.

Does that make sense?
