HopBot_botpress
by Erik
JavaScript
console.log('botpress');
var script = document.createElement('script');
script.src = 'https://cdn.botpress.cloud/webchat/v1/inject.js';
document.head.appendChild(script);
var styleElement = document.createElement('style');
styleElement.innerHTML = '#bp-web-widget { z-index: 99999; }';
document.head.appendChild(styleElement);
var botId = "9f6fb917-654f-42f3-a9d0-9d89aaba3678"
script.onload = function() {
if (window.botpressWebChat && typeof window.botpressWebChat.init === 'function') {
window.botpressWebChat.init({
"composerPlaceholder": "Ask me anything about digital marketing",
"botConversationDescription": "Ask me anything about digital marketing",
"botId": botId,
"hostUrl": "https://cdn.botpress.cloud/webchat/v1",
"messagingUrl": "https://messaging.botpress.cloud",
"clientId": botId,
"lazySocket": true,
"botName": "HopBot",
"avatarUrl": "https://static.labsbit.com/static/hopbotlogo.png",
"frontendVersion": "v1",
"enableConversationDeletion": true,
"showPoweredBy": false,
"stylesheet": "https://static.labsbit.com/static/hopbot.css",
"userData": {"url": window.location.href},
});
window.botpressWebChat.onEvent(function (event) {
//console.log("EVENT......................");
if (event.type === 'LIFECYCLE.READY') {
console.log("LIFECYCLE.READY");
}
if (event.type === 'LIFECYCLE.LOADED') {
// window.botpressWebChat.sendEvent({ type: 'show' })
console.log("LIFECYCLE.LOADED");
window.botpressWebChat.sendEvent({ type: 'createConversation' })
}
},['TRIGGER', 'LIFECYCLE.READY', 'LIFECYCLE.LOADED']
);
} else {
console.error("botpressWebChat.init is not available!");
}
};
///////////////////////////////////