fancy-monkey-19130
07/24/2023, 9:59 PM<script src="https://cdn.botpress.cloud/webchat/v0/inject.js"></script>
<script>
window.botpressWebChat.init({
// bot configuration
<script src="https://mediafiles.botpress.cloud/c7353314-2f42-47e8-a8ca-138ba5e0db89/webchat/config.js" defer></script>
});
// executes when the button is clicked
document.getElementById('startCalculation1').addEventListener('click', function() {
// open the chatbot because the trigger doesn't work if the chatbot isn't open
window.botpressWebChat.sendEvent({ type: "show" });
// workaround using 'Timeout' cause the 'onEvent(function(), ["LIFECYCLE.LOADED"])' doesn't work and we need to trigger this only after the chatbot is loaded
setTimeout(function() {
window.botpressWebChat.sendPayload({
type: "trigger",
payload: {}
});
}, 3500); // 3.5 seconds, not too short to let it load, not to long to have a message too delayed
});
</script>