function vh_bot_Inject(baseUrl, apiBaseUrl, tid, cid, oid, responseStorage, width = 350, heightMargin = 100, offsetX = 40, offsetY = 40, isLeft = false, theme = 'Blue', botName = 'Rita', botLogo = null, botLogoStyle = null, useExternalSubmitUrl = false, externalSubmitUrl = '', slackWebhookUrl = '') { window.vh_bot_vars_baseUrl = baseUrl; window.vh_bot_vars_apiBaseUrl = apiBaseUrl; window.vh_bot_vars_tid = tid; window.vh_bot_vars_cid = cid; window.vh_bot_vars_oid = oid; window.vh_bot_vars_responseStorage = responseStorage; window.vh_bot_vars_BotName = botName; window.vh_bot_vars_BotLogo = botLogo; window.vh_bot_vars_BotLogoStyle = botLogoStyle; window.vh_bot_vars_UseExternalSubmitUrl = useExternalSubmitUrl; window.vh_bot_vars_ExternalSubmitUrl = externalSubmitUrl; window.vh_bot_vars_SlackWebhookUrl = slackWebhookUrl; vh_bot_InjectCss(); vh_bot_InjectHtml(width, heightMargin, offsetX, offsetY, isLeft, theme); } function vh_bot_HandleToggle() { window.vh_bot_vars_State = window.vh_bot_vars_State ? false : true; let iframeRef = document.getElementById('vh-bot-iframe'); let containerRef = document.getElementById('vh-bot-container'); if(vh_bot_vars_State && iframeRef.src === '') { let iframeUrl = `${vh_bot_vars_baseUrl}/?apiBaseUrl=${vh_bot_vars_apiBaseUrl}&tid=${vh_bot_vars_tid}&cid=${vh_bot_vars_cid}&oid=${vh_bot_vars_oid}&theme=${window.vh_bot_vars_Theme}&responseStorage=${window.vh_bot_vars_responseStorage}`; if(vh_bot_vars_BotName) iframeUrl += `&botName=${window.vh_bot_vars_BotName}`; if(vh_bot_vars_BotLogo) iframeUrl += `&botLogo=${window.vh_bot_vars_BotLogo}`; if(vh_bot_vars_BotLogoStyle) iframeUrl += `&botLogoStyle=${window.vh_bot_vars_BotLogoStyle}`; if(vh_bot_vars_UseExternalSubmitUrl) { iframeUrl += `&useExternalSubmitUrl=${window.vh_bot_vars_UseExternalSubmitUrl}`; iframeUrl += `&externalSubmitUrl=${window.vh_bot_vars_ExternalSubmitUrl}`; } if (vh_bot_vars_SlackWebhookUrl) { iframeUrl += `&slackWebhookUrl=${window.vh_bot_vars_SlackWebhookUrl}`; } iframeRef.src = iframeUrl; } iframeRef.style.transform = `scale(${window.vh_bot_vars_State ? 1 : 0})`; iframeRef.style.opacity = window.vh_bot_vars_State ? 1 : 0; iframeRef.style.display = window.vh_bot_vars_State ? 'block' : 'none'; containerRef.style.maxWidth = window.vh_bot_vars_State ? '' : '55px'; containerRef.style.maxHeight = window.vh_bot_vars_State ? '' : '65px'; } function vh_bot_InjectHtml(width, heightMargin, offsetX, offsetY, isLeft, theme) { const ThemePrimaryColors = { DarkBlue: '#2F3053', Blue: '#0658EA', Orange: '#DE4A17', DarkRed: '#512d2d', Red: '#D01616', Pink: '#de17d4', Purple: '#8317de', DarkPurple: '#462d51', DarkGreen: '#2d512d', } window.vh_bot_vars_Theme = theme; let botContainer = document.createElement('div'); botContainer.id = 'vh-bot-container'; botContainer.style.bottom = `${offsetY}px`; botContainer.style.width = `${width}px`; botContainer.style.height = `calc(100vh - ${heightMargin}px - ${offsetY}px)`; botContainer.style.alignItems = isLeft ? 'flex-start' : 'flex-end'; botContainer.style.zIndex = 100000; if(isLeft) botContainer.style.left = `${offsetX}px`; else botContainer.style.right = `${offsetX}px`; let botIconContainer = document.createElement('div'); botIconContainer.id = 'vh-bot-icon-container'; botIconContainer.style.backgroundColor = ThemePrimaryColors[theme] ? ThemePrimaryColors[theme] : ThemePrimaryColors.Blue; botIconContainer.onclick = vh_bot_HandleToggle; let botIcon = document.createElement('svg'); botIcon.innerHTML = ` `; botIcon.id = 'vh-bot-icon'; let botIframe = document.createElement('iframe'); botIframe.id = 'vh-bot-iframe'; botIframe.style.transformOrigin = `bottom ${isLeft ? 'left' : 'right'}`; botIconContainer.append(botIcon); botContainer.append(botIframe); botContainer.append(botIconContainer); document.getElementsByTagName('body')[0].append(botContainer); } function vh_bot_InjectCss() { var css = ` #vh-bot-container { position: fixed; display: flex; flex-direction: column; justify-content: right; animation-direction: alternate; transition: all 0.3s; } #vh-bot-icon-container { display: flex; justify-content: center; align-items: center; width: 55px; height: 55px; min-height: 55px; border-radius: 50%; opacity: 0.75; transform: scale(1); transition: transform 0.3s; margin-top: 10px } #vh-bot-icon-container:hover { opacity: 0.9; } #vh-bot-icon { margin: 0; padding: 0; margin-top: 2px; height: 60%; } #vh-bot-iframe { width: 100%; height: calc(100% - 50px); background-color: transparent; border: none; border-radius: 10px; overflow: hidden; zoom: 0.8; box-shadow: 0px 0px 20px 0px #00000090; transform: scale(0); transition: all 0.1s; } `; var style = document.createElement('style'); if (style.styleSheet) style.styleSheet.cssText = css; else style.appendChild(document.createTextNode(css)); document.getElementsByTagName('head')[0].appendChild(style); }vh_bot_Inject('https://chat.rosie.cloud', 'https://rcb.vianova.ai/api', '606ec55572c5570e93e8a9d7', '606ec56372c5570e93e8a9d8', '606ec4e172c5570e93e8a9d6', 'VARIABLES', 400, undefined, 40, 40, false, 'Orange', 'IP Petrol', undefined, undefined, undefined, undefined, undefined);