project_code_loader

by Erik

HTML

<!DOCTYPE html>
<html lang="en">
  <header></header>
<body>
</body>
</html>

JavaScript

console.log('botpress');

var script = document.createElement('script');
script.src = 'https://cdn.botpress.cloud/webchat/v1/inject.js';
document.head.appendChild(script);

var botId = "c92ae231-8748-420b-a691-4b15434670f3";

// script.onload = function() {
window.onload = function() {
    if (window.botpressWebChat && typeof window.botpressWebChat.init === 'function') {
    	
     window.botpressWebChat.init({
		    "composerPlaceholder": "Chat with Homefinders Assistant",
		    "botConversationDescription": "Let me help you",
		    "botId": botId,
		    "hostUrl": "https://cdn.botpress.cloud/webchat/v1",
		    "messagingUrl": "https://messaging.botpress.cloud",
		    "clientId": botId,
		    "lazySocket": true,
		    "botName": "Assistant",
		    "avatarUrl": "https://static.labsbit.com/static/icons8-trans.png",
		    "frontendVersion": "v1",
		    "enableConversationDeletion": true,
   		    "showPoweredBy": false,
   		    "stylesheet": "https://static.labsbit.com/static/hfstyle.css",
			"userData": {"url": window.location.href},
		});
    
      window.botpressWebChat.onEvent(
        function (event) {
        	console.log("event (bp)", event);
          console.dir(event);
          if (event.type === 'TRIGGER') {
            // window.botpressWebChat.sendEvent({ type: 'show' })
            console.log("botpress: onOpenChat -> ", event);
            window.botpressWebChat.sendPayload({
			  type: "trigger",
			  payload: {url: window.location.href}
			});
          }
        },
        ['LIFECYCLE.READY']
      );
  
    } else {
        console.error("botpressWebChat.init is not available!");
    }
};