Best way to import user info into rasa

Suppose I am running a rasa bot on my own website that requires users to log in. What is the best way to pass in personal information, such as the user’s name and other info to maintain state? I don’t want my bot to have to start from scratch every time he/she logs in.

Hi @MikesUsingRasa

I think your question is unclear to me. Login into what?, your website or on chatbot. If it’s in website then you need to find a way to pass it to chatbot user session. Also you can store information passed in previous session by user into some database. So next time when user logs in and start chatting the bot, bot will already know what conversation user have done in past.

For example: for a E-commerce company, user may have purchased a few product by chatting or from your website. That information should be accessible to bot using some DB arrangment. One complex solution could be use of knowledge graphs to store such information for better and faster retrievals.

@athenasaurav, you’ve understood me correctly…when a user logs into a website. How would I pass that information, say from a database, into the chatbot user session? Or more simply, how could I pass a unique code that identifies the current user, so that a custom action can look up info in a database on that particular user?

For example, imagine I’ve alreadly logged into my user account on the website, and then I decide to start a chat with a bot. I want the bot to already know my name (or be able to look it up) and perhaps other info about me (such as my purchases).

Hey @MikesUsingRasa

I m not sure how to pass that information from your logged in screen to chatbot widget. This is not a NLP or RASA task but simply a frontend task. Some frontend guy might help you here. All you need is to create a variable which widget looks for when starts and if it doesn’t found it can send RASA a command to ask user to give his user id (the variable). Since it all in frontend the user id variable can be passed from your e-commerce website to the chatbot widget easily.

Thanks @athenasaurav !

That sounds like a good place to start. I have a follow up question though.

Suppose I want to develop the bot now and worry about the frontend later. If I follow your suggestion and create a variable that the bot will look for and if it doesn’t find it (or the variable is None), the bot will request the info. My follow up question is where would I create/store the variable. If I create the variable in actions.py, won’t the variable be set for all sessions? In other words, won’t the entered id, be set for all users, regardless of their session id, or am I getting that wrong? For example, when I set a variable user_name=“Mike” in actions.py, the bot now thinks everyone is named “Mike”.

Maybe the user’s info necessarily needs to be saved to slots? If that’s the case, is it possible for slots to be set via the frontend?

I will suggest that creating an entity/slot which will get autofilled by frontend if the user is logged in. Now you can trigger action_greet which will trigger in start and will check if the entity/slot is filled or not then will ask the user for its user name(if not filled) or if it’s already filled it can greet user like “Hi username”

1 Like

You can pass information like this using metadata on the REST or Socket channel. The botfront, scalable minds and rasa widgets all support this.

You can also write a custom action that looks up info via an API or database.

1 Like