First and foremost, generate the Botnation's code allowing you to activate your chatbot on your website, here's the how-to.
Then, delete the first line :
<script type="text/javascript">
And the last one :
</script>
Insert the code code in a Javascript function :
function launchChatbot() {
(window as any).chatboxSettings = {
appKey: 'xxxx',
websiteId: 'xxx',
language: 'fr',
...
};
(function (d, s, id) {
let js: any, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = 'https://cbassets.botnation.ai/js/widget.js';
js.async = true;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'chatbox-jssdk'));
}
This function will launch the chatbot as soon as you trigger it. You can launch it by clicking on a button after a delay or another Javascript action.
Here's an exemple of a chatbot launch (via the launChat feature we just created) with a 10s delay (10000ms) :
setTimeout(launchChatbot, 10000);