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

▼魔方 西西 提交于 2021-01-29 04:44:12

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/62058847/how-to-get-the-user-login-details-from-java-script-based-web-browser-in-rasa-cha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!