gorgeous-forest-752
06/04/2025, 6:07 PMjs
// the lines below were removed
window.botpress.on("webchat:ready", () => {
window.botpress.open();
});
// the line below is added to the end of the script tag below the init call
setTimeout(() => {
window.botpress.open();
}, 1000)
Hi!
I'm trying to set up the bot in a way where the conversation automatically launches upon loading the host link.
Following the embed instructions provided in the HTML div section of the docs (https://botpress.com/docs/webchat/embedding-webchat), the webchat injection doesn't seem to automatically fire off in versions 2.3 and higher, where even if I have window.botpress.toggle() (or window.botpress.open() for that matter as well) within the window.botpress.on(webchat:ready...) snippet, it still seems to only start the conversation when I click on the .bpFab widget.
I am able to get the conversation to automatically open when using versions 2.2 or lower, but am concerned about functionality issues by using an older version of the injection. Just wondering if there was a way to get the window to automatically toggle on for 2.5 (or if I'm not really losing anything by using the 2.2 version)?
For reference here is the .html file in question below:
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Title</title>
</head>
<body>
<div id="webchat-container" style="position: relative; width: 100%; height: 100%;">
<script src="https://cdn.botpress.cloud/webchat/v2.5/inject.js"></script>
<script>
console.log("Step 1") // This is logged in console
window.botpress.on("webchat:ready", () => {
console.log("Step 2") // Does not log in console unreachable?
// window.botpress.open();
window.botpress.toggle(); // both lines seem to not fire off on load for 2.3, 2.4, 2.5
console.log("Step 3") // Does not log in console either
});
window.botpress.init({
"bot init info here"
});
</script>
<style>
#webchat-container {
position: relative;
width: 100%;
height: 100%;
}
.bpFab {
display: none;
}
.bpWebchat {
position: absolute !important;
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
width: 100% !important;
height: 100% !important;
}
</style>
</div>
</body>
</html>
Thanks in advance!prehistoric-airplane-85682
06/04/2025, 7:33 PMlimited-lunch-44607
06/10/2025, 8:57 AMgorgeous-forest-752
06/10/2025, 11:03 AMjs
window.botpress.on("webchat:ready", () => {
window.botpress.open();
});
So I have both that line and the delay at the bottom of the script tag body
I’m not sure how it’ll work with wordpress though, good luck!