https://discord.gg/botpress logo
My dumbest answer* read this doc https://botpress-...
# 💻developers
p
I may have the dumbest question, however, here I am. 🙂 I am new to BotPress and have spent days and many iterations trying to get a single variable to pass into a bot from my website. I "think" I have followed every example. I am simply trying to pass a businessId from my embed code. within botpress.init I have defined businessId in userData and it is showing perfectly in console. However, I cannot seem to get botpress to receive/store the variable with any configuration of syntax (and I think I have tried every documented example short of Klingon). Is there perhaps some sort of toggle or config setting that I am missing to allow variables to be passed? I have attempted may iterations through Scripts, URL parameters, iFrame etc... Tearing my hair out because passing this variable should have been the easiest part of my project. I appreciate any guidance here or a simple example of an embed script passing a variable and the config to receive it on any GetUserData, or Execute or Text card. I am obviously overlooking a blindingly simple config here. 🙂 Thanks.
w
My dumbest answer * read this doc https://botpress-docs.readme.io/docs/user-data * read my tutorial, there is the workflow in hub, https://discord.com/channels/1108396290624213082/1294770912155013163
p
Lol, I appreciate that and yes I have seen that doc. "I understand the suggestion to use Get User Data with {{ event.userId }}, but this is unrelated to my issue. I am specifically trying to pass a custom frontend variable (businessId) to my Botpress bot via the Webchat embed script, using the "officially documented" method (userData). The documentation here clearly states we can send custom frontend data via: window.botpressWebChat.init({ botId: "", clientId: "", userData: { businessId: "12345" } }); And retrieve it in Botpress backend via: javascript const businessId = event.state.user?.userData?.businessId; But this officially documented method doesn't actually work on my Botpress Cloud instance, despite multiple exact attempts. Additionally, newer documentation (botpress.com/docs/user-data) shows an alternative method (user.data). I've also tested that without success. where I need more clarify: Is the officially documented userData method working on Botpress Cloud Webchat v2.3? Has there been an undocumented change to the required data structure (userData vs user.data)? If both approaches (userData and user.data) fail, how can I reliably pass custom frontend variables into my bot?"
@white-nest-40686 I am working through your tutorial right now to see if I have missed anything (which likely i have) Thank you for sending that over
b
Did you figure out an answer to this. i am also pulling my hairs at this stage and not able to figure out how to pass the basic user email and name from front end