Retrieve User Logged into Browser

Hi,

I have developed a chatbot, I need to obtain the user logged into the browser to use it as “sender” for the REST call, any thoughts on how to get this information using Python?

PS: Front -End is written in Python using Flask

The chatbot widget in the browser would typically create a sender_id for the user and pass it into the Rasa REST or SocketIO channel. The widget can use anything for the sender_id.

The Rasa chatbot can access the sender_id via actions. You can also customized the channel code to pass additional metadata to and from the client app.

Greg

can we use the sender_id to fetch logged-in user’s information?

yes, you’re front end UI would set a sender_id and could also pass other metadata / user profile info about the user. A custom action can use the sender_id and metadata to lookup additional information.

2 Likes

i am using socketIO channel and I want my front-end to send sender_id as something specific to logged-in user, can you please guide me where do I have to make changes in front-end to achieve this? I am really out of clue right now.

The botfront widget uses SocketIO. You can see their code set the session_id here

2 Likes

okay thanks. But i am using android and ios app to deploy my bot. If i make the payload to be like { “sender”: “2344” “message”: “hello” }

where sender being the current logged-in user_id, will it be working fine? then I can fetch the sender_id in my custom actions to make api calls?

The steps for using the socket io channel are explained here.

You can then capture the session id in the action_session_start action. You’ll also find a description of the session_started_metadata event to capture any other metadata passed from your Android app.

1 Like