userData field gets inconsistently ignored in the ...
# 🤝help
l
Botpress (Webchat) supports to pass custom “userData” in the window.botpressWebChat.init(...) function. That is helpful to pass e.g. the current URL of the page etc. The data in userData can be read with the “Get User Data” Card in botpress. **Problem**: Sometimes it works to read the userData and sometimes it returns an empty object, although everything stays the same. In this 2:30 min video I demonstrate the issue: https://app.usebubbles.com/rs8zCL19f1BEmpgDR492Au/user-data-issue jsFiddle code for testing: https://jsfiddle.net/slimtech/6v5domur/1/ Further information: Information about userData from the documentation: https://botpress.com/docs/cloud/channels/webchat/#send-user-data-from-your-website-to-botpress Am I doing something wrong?
e
Hello @loud-portugal-76830 thanks for the detailed info!
l
@early-train-33247, thank you for the reply! I tried to read it from event.payload.payload.url, but there was no payload in event.payload. See the screenshot for the changed bot. It seems that event.payload only contains my last message. Here is a 1 min video that's showing the applied changes: https://app.usebubbles.com/sj8FxqAXigfbuMgmZKYE4h/02-payload-issue You can see here the result: https://jsfiddle.net/slimtech/6v5domur/1/ At which position in the flow do I need to read it? I tried: 1. At the start of the flow 2. After the "Get User Data" Card 3. I tried within an "Execute code" card and Text card
e
Hey @loud-portugal-76830 let me take a look
Sorry since you arelady save the user data to a workflow variable (userData), there's no need to read it at event.payload
I managed to reproduce the issue some times but not other times.
Just FYI, you can use the `init `function with the userData only once. You can't
init
the webchat again with new data nor using
mergeConfig
.
l
Thank you, here are my comments inline: > 1. Since you already save the user data to a workflow variable (userData), there's no need to read it at event.payload Okay. Although if I leave “Store output value in” in the “Get User Data” Card empty, it doesn’t change the behaviour. But this is probably not a problem for now. > 2. I managed to reproduce the issue some times but not other times. Can you confirm this is a botpress issue and I can’t fix it on my side? > 3. Just FYI, you can use the init function with the userData only once. You can't init the webchat again with new data nor using mergeConfig. Thanks, I saw it here in the documentation: https://botpress.com/docs/developers/webchat/controlling-webchat-using-js/#send-user-data-from-your-website-to-botpress
e
Hey Erik, I'm going on vacation but I'm leaving you on @acceptable-gold-88171's capable hands
a
Hi @loud-portugal-76830 , do you have a report id we can use to try it out? as far as I know it works when I do it on my end, so i'd like to have a look at your bot.
l
Hi @acceptable-gold-88171 , yes sure here are the requested details: 1. Report id: b798c9f2-65e5-423f-9ac8-2d30aa5fe610 2. I checked again if the issue still exists and I get the same issue (video): https://app.usebubbles.com/8iTUfwfDkaTvpnvxAz7m7C/user-data-botpress-issue 3. Not sure if helpful: Id of the log entries related to the "Get User Data" card that is failing to read the data: 9e6891c5ac
f
@loud-portugal-76830 you have to start conversation by trigger to get event.payload.payload.variable, as I described here: https://discord.com/channels/1108396290624213082/1164281397893136384/1171391954014183425 I use this method and it is 100% reliable.
e
Thanks for the information @famous-bird-23831!
@loud-portugal-76830 can you try this solution and let us know if it works?
a
can you describe the solution ?
29 Views