https://discord.gg/botpress logo
Automatic opening of the bot on the website
# 🤝help
t
Hello, My name is Philipp. I am relatively new to Botpress. I use Botpress to create and sell chatbots for other companies. So I run an agency. Unfortunately, I have been stuck on a problem for days and can't seem to get any further. I want my bots to have the following functions: Either the bot should open automatically on my customers' websites, or a red “1” should appear in the bot widget. This way, visitors to the website can see that they have received a message from the bot without having to open it. I hope someone can help me with this problem. I would be very grateful to that person. Best regards, Philipp
a
For: "Either the bot should open automatically on my customers' websites" you can use window.botpress.open method to open bot when website and bot is loaded For: "or a red “1” should appear in the bot widget" use custom javascript to access botpress embedded code and display red "1"
g
use botpress inject script in head, then in body manually use the init script, but register this listener first
Copy code
// Register listener FIRST, before any initialization (BEFORE window.botpress.init)
                window.botpress.on('webchat:initialized', async () => {
                  console.log('Webchat initialized, setting ready state after delay');
                  setTimeout(() => {
                    window.botpress.open();
                  }, 500); // 500ms delay as recommended
                });
webchat emits the initialized event when its ready to be opened, ^ then if you want to send events to your bot, also register the
window.botpress.on('webchat:ready'.....
listener and put your logic in there
the listeners must be registered BEFORE you call the init script/
2 Views