https://discord.gg/botpress logo
Passing user data on webchat init - not working - ...
# 🤝help
t
If anyone has some tips on this I would be very appreciative 🥹 The instructions to pass user data from my app to my bot here do not work for me: https://botpress.com/docs/webchat/interact/send-user-data I have read through lots of threads on this issue on here and it seems like a lot of people have a similar problem. I have tried many of the proposed solutions and still can't get it working. I am firstly trying to see if the user data being sent with window.botpress.init appears in the "event" object. I can see placeholders for user data in several places, e.g. - user.userData - "variable_values": { "userData": {} } - conversation.customData I have tried setting multiple of these variables but nothing changes in the raw "event" object. I have also tried matching up the variables in the code to the variables set inside the botpress UI (bottom left corner). Any help would be much appreciate!! Example of the code I am trying to use
Copy code
<script>
    const firstName = "John";
    const lastName = "Doe";
    const email = "john.doe@example.com";

    window.botpress.init({
        "botId": "",
        "configuration": {
            "website": {},
            "email": {},
            "phone": {},
            "termsOfService": {},
            "privacyPolicy": {},
            "variant": "soft",
            "themeMode": "light",
            "fontFamily": "inter"
        },
        "clientId": "",
        "user": {
            "userData": {
                "firstName": firstName,
                "lastName": lastName,
                "email": email
            },
            "data": {
                "firstName": firstName,
                "lastName": lastName,
                "email": email
            }
          }
    });
g
you want data from your data base to be used in a botpress conversation? you want to pass data to the bot basically?
wait the bot to be initialised ie
Copy code
if (window.botpress.initialized) {
    const customPayload = {
    "firstName": "firstName"
    ...... etc
}

    await window.botpress.sendEvent(customPayload)
}
then use the advanced trigger to catch it, or a hook (before incoming)
t
Thanks so much @gentle-policeman-89141 for your response! Will give this a shot