How to embed a pop bot with automatic load and button

Pau Sanchez Updated by Pau Sanchez

Below is the sample code of a site that will trigger a pop up as soon as the site is loaded, and a button that if clicked it will reopen the bot once is closed

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<button type="button"onclick="openLandbot()">OPEN BOT</button>

//To check if snippet has already been added to the DOM
var scriptUploaded = false;

//Check and ADD main script or open the bot
function openLandbot(){
if (scriptUploaded){
} else {
scriptUploaded = true;
var script = document.createElement("script");
script.type = "text/javascript";
script.setAttribute("SameSite","None; Secure");
script.onload = triggerLandbot()
script.src = "";

//Once the main script has been loaded, create new object and open pop up

function triggerLandbot(){
var script = document.createElement("script");
script.innerHTML = `var myLandbot = new LandbotPopup({ index: '', //Please change url according to your needs open: true, launcherOptions: { enable: false } });`;


How did we do?

How to launch a Landbot by clicking a button

How to trigger events and/or pass values from Landbot to the container site