https://discord.gg/botpress logo
Unable to access userData in bot
# 🤝help
b
Hello! I am attempting to pass user details from my website to a botpress widget but am unable to successfully see that data in Botpress. The core issue is that despite multiple attempts to pass the company and person data to the Botpress bot using various methods (including window.botpress global objects, initialPayload, user objects, and currently userData configuration), the data is not being successfully transmitted to or received by the Botpress bot. Additional details are included down below, any help would be appreciated to resolve this issue. Technical Environment- Botpress Webchat Version: @square-energy-41150/webchat ^3.1.0 React Version: ^18.3.1 Framework: Vite + React + TypeScript Data Flow Architecture Data Source: (URL Parameters) Data Processing Chain: URL Params → useUrlParams() → Index.tsx → BotpressChat.tsx → Webchat Component Current Implementation Details Webchat Configuration Structure:
Copy code
<Webchat
clientId="28a344bb-2566-496b-b137-45f6684b413d"
configuration={{
botId: "91a6841c-24c3-4f08-8794-11b77358aff8",
version: "v1",
// ... other config properties
userData: {
company: company,
person: person
}
}}
/>
** Key Implementation Points:** Method: Using userData field in the Webchat configuration object Data Format: Flat key-value pairs ({company: string, person: string}) Data Types: Both fields are strings Timing: Data is passed during component initialization Data Validation: TypeScript interface ensures type safety:
Copy code
interface BotpressChatProps {
company: string;
person: string;
}
** Previous Attempted Methods (That Failed):** ❌ user field in configuration ❌ initialPayload field in configuration ❌ Nested object structures like user.leadInformation