https://discord.gg/botpress logo
Timing Between Botpress Initializing on Page and A...
# 🤝help
g
Problem: I have a webchat integration that waits for
window.botpress && window.botpress.initialized === true
, then immediately sends an event to the bot on page load. However, even though this condition is met, sending the event sometimes throws an error "`Botpress webchat is not initialized. Please call botpress.init() before sending events.`" suggesting the bot isn't fully ready yet, even though initialized === true (window.botpress.init has been called upstream) and the global functions are available. Question: Should there be a timing delay between when window.botpress.initialized === true and when the bot can actually receive events (ie is this intended)? Is there a better guard to detect when the bot is actually ready to receive events from my web app? Potential Solutions I'm Considering: 1. Add a fixed delay (e.g., 500ms-1s) after initialized === true 2. Use a different condition to check if events can be sent thanks in advance!
I think i fixed by moving event sending to webchat:ready instead of webchat:initialized . Just to be sure, is webchat:ready the correct event that signals the bot is ready to receive events?