How to get the user login details from java script based web browser in RASA chatbot

Question:

Web bot is integrated in javascript based website ,when user login in website then they can access the chatbot icon.

When they open it chatbot starts ,but currently it doesn’t collect user data .
But , now user data is important because further we want to call actions based on user id.

If we will be able to know the user id then we can send the specific query to user from bot.

If user is US based then bot should only reply US region based data ,but if user is APAC then bot should only provide him/her APAC based data from backend.

We have nlu.md, stories.md and domain.yml file and also actions.py file which handles API call to backend.
Please Help.

Asked By: AllTech

||

Answers:

I assume you are using the Rasa Web Chat widget: there is a way to pass some custom data from the browser to the Rasa server, using the customData (for each request) and/or initPayload (only when the conversation starts) parameters

 <script>
   WebChat.default.init({
    selector: "#webchat",
    initPayload: "/get_started",
    customData: {"userId": "1"}, 
    socketUrl: "http://localhost:5500",
    socketPath: "/socket.io/",
    title: "Title",
    subtitle: "Subtitle",
  })

The widget provides also an API to send a message (WebChat.send) in case you need the flexibility to decide when to send a payload to the Rasa backend

Answered By: Beppe C