Get User Data from Website
# 🤝help
d
#help I have implemented the steps to get data from website to botpress. Somtimes it works. Sometimes it gives {}. What’s happening here
q
d
Hello. I wanted to pass userData in the initial function to get user data from the website to chatbot
@quick-musician-29561 do you have any other workaround for this?
q
Now you have made progress, you can store the User Data from the website already?
If you solved that 💎 then the problem is to clear the User Data?
d
My requirement is to integrate bot with a webapp. now when i login to the webapp, the bot captures the user info like email, name, etc. now if i logout and again to the webapp, the bot is still capturing previous login info only.
q
Understood! 🫡
I have never done that with Botpress, but I can try to build something similar
Together we will solve this eventually
d
the thing is if there is any way to clear session storage by page refreshes, this will work
q
I'll get back to you when I have tested this and tried everything
d
otherwise it should generate a new user id everytime we refresh the page
sure
Sure. Thank you
q
Those your instructions when you have already tried different things, will help a lot ⚡
I think the problem is in the chatbot, not in the website at all. If now you can collect username and password from website, and send that to chatbot. But if the next user reloads the page, and chatbot is still there, it uses the previous chatbot users info. So those need to be deleted / cleared on chatbot? Normally if it's still on the same browser or tab, it's still the same user 💡 (not the case with shared computers in workplaces etc.)
or maybe I'm wrong, that's why I asked help from 🦸‍♂️ BotBassadors 🦸‍♂️
d
Correct
q
@damp-parrot-42529 In your logout button
Copy code
js
      const logoutButton = document.getElementById('logout');
add this to clear the user data also on Botpress side
Copy code
js
          logoutButton.addEventListener('click', function() {
            const nameValue = document.getElementById('name').value;
            const emailValue = document.getElementById('email').value;
            window.botpressWebChat.sendPayload({
              type: 'text',
              text: "User logged out",
              payload: {
                name: "",
                email: "",
              }
            })

          });
Try if that works for you, otherwise we'll continue 🛠️
d
Sure. Thanks for this. I will give you an update soon
l
hi did you able to solve problem , also i noticed one thing , when we pass userData in script it will only captured once in studio/botpress side, when we logout and login agian it shows empty object,
if you have found something can you please look in to this
13 Views