https://discord.gg/botpress logo
Hi, I'm having trouble embedding the v1 webchat sc...
# 💻developers
b
Hi, I'm having trouble embedding the v1 webchat script into my React 19 + Vite application. I keep getting a TypeError: window.botpress is undefined when the script tries to initialize, suggesting a timing issue with inject.js. My goal is to have the webchat open automatically on page load using the script injection method. I've tried loading the inject.js and the bot-specific config script (files.bpcontent.cloud/...js) in both and , with and without defer. I've also tried using an inline script to extract the config and poll for window.botpress.init before calling it, and using the webchat:ready event to call window.botpress.open(). None of these approaches have reliably prevented the timing error in the Vite dev environment. The same script setup works fine in a static HTML file. What's the recommended way to handle this script loading sequence and auto-open in a React/Vite SPA?