Table of Contents

Open LiveChat bot as soon as page loads (3 ways)

Pau Sanchez Updated by Pau Sanchez

Maybe we want to display the LiveChat as soon as the page is loaded to greet customers, here are three ways to do it:

In Landbot 3

Display bot Always and As Soon As the page is loaded

<script>
myLandbot.onLoad(function() {
myLandbot.open()
})
</script>

Display bot Always and 3 seconds after the page is loaded

<script>
myLandbot.onLoad(function() {
setTimeout(function(){
myLandbot.open()
},3000)
})
</script>

Display bot only to new visitors

<script> 
myLandbot.onLoad(() => {
var visitor = localStorage.getItem('firstvisit')
if (visitor != 'true'){
localStorage.setItem('firstvisit', 'true');
myLandbot.open() } })
</script>

Display bot only to new visitors after 3 seconds

<script> 
myLandbot.onLoad(() => {
var visitor = localStorage.getItem('firstvisit')
if (visitor != 'true'){
localStorage.setItem('firstvisit', 'true');
setTimeout(function(){
myLandbot.open()
},3000) } })
</script>

We will always locate the code right after the one we used to embed our bot

In Landbot 2

Display bot Always and As Soon As the page is loaded

<script> 
myLandbot.on('landbot-load', () => {
myLandbot.open()
})
</script>

Display bot Always and 3 seconds after the page is loaded

<script> 
myLandbot.on('landbot-load', () => {
setTimeout(function(){
myLandbot.open()
},3000)
})
</script>

Display bot only to new visitors and 3 seconds after the page is loaded

<script> 
myLandbot.on('landbot-load', () => {
var visitor = localStorage.getItem('firstvisit')
if (visitor != 'true'){
localStorage.setItem('firstvisit', 'true');
myLandbot.open() } })
</script>

We will always locate the code right after the one we used to embed our bot:

Extra: 'Pop' Sound when bot opens

Applicable only when the user has already interacted with page

To create a sound notification when the bot opens we can add the following to the embed code:

var snd = new Audio('https://codeskulptor-demos.commondatastorage.googleapis.com/pang/pop.mp3');
snd .play();

This code will go in the timeout function

You can add any MP3 as long as it's publicly hosted with a valid url

How did we do?

How to launch a Landbot by clicking a button

Contact