userData not working
# 🤝help
b
Hi, I have some problems sending user data to the bot in my react app. This is the script I'm using:
Copy code
js
import React, { useEffect } from 'react'
import { useAuthContext } from '../../context/AuthContext';

export const WebchatChatbot = () => {
    const { user } = useAuthContext();
    useEffect(() => {
        if (user?.id) {
            const script = document.createElement('script')
            script.src = 'https://cdn.botpress.cloud/webchat/v1/inject.js'
            script.async = true
            document.body.appendChild(script)

            script.onload = () => {
                window.botpressWebChat.init({
                    "composerPlaceholder": "Chat with uptibot",
                    "botConversationDescription": "Start a conversation with the bot designed for uptitude.",
                    "botId": "",
                    "hostUrl": "https://cdn.botpress.cloud/webchat/v1",
                    "messagingUrl": "https://messaging.botpress.cloud",
                    "clientId": "",
                    "webhookId": "",
                    "lazySocket": true,
                    "themeName": "prism",
                    "frontendVersion": "v1",
                    "showPoweredBy": true,
                    "theme": "prism",
                    "themeColor": "#2563eb",
                    "userData": {
                        "user_id": user?.id,
                    }
                });
            }
        }
    }, [user])

    return <div id="webchat" />
}
When I'm trying to access this data in the botpress cloud it returns an empty JSON, I think i followed the docs correctly, but something is missing, can someone help me?
a
@best-salesclerk-45195 did you retry since yesterday ?
it works perfectly on my end
1 sec, I was using webchat v0, let me try on v1
b
yeah, I tried this morning, like 6 hours ago
a
works on v1 too
In your config,
botId
,
clientId
and
webhookId
are empty strings. Did you remove these ID's just to share the config with us or is it also empty when you use your bot ?
b
yeah I removed them just to show the config
a
@rich-battery-69172
r
@best-salesclerk-45195 hey can you share with me your botId or a problem report? @square-energy-41150
s
# Sending a Problem Report Here's how to send the Botpress Team a problem report: 1. In the Botpress Cloud Studio, locate the "Help" icon in the bottom left corner of the screen. 2. Click "Report a problem" and follow the steps on the screen. 3. Copy the Report ID to your clipboard and provide it to a member of the Botpress Team on Discord.
r
If that's of any help, here's how I got it setup on my side: Embed Script https://codepen.io/slvnperron_bp/pen/YzMVQZr Workflow:
b
hi, thanks for your fast reply and your attention, still facing the same problem, I tried to recreate an easier scenario:
If you need it, here is my botId:
Copy code
python
"botId": "8bde2552-ddb0-4513-bdd7-8f55765530fe",
@rich-battery-69172 hi, news for this?
r
@best-salesclerk-45195 hey sorry about the silence, I tried to replicate without success. are you free for a quick screenshare right now?
b
yeah, whenever you want
3 Views