Я хочу, чтобы мой чат-бот был открыт, когда пользователи заходят на веб-страницу, не нужно нажимать на виджет.С моим кодом это работает, но окно чат-бота закрывается немедленно ...
Этот метод не очень хорош, но я не нахожу нативную настройку Botpress для этого.
У вас есть идея?В идеале сценарий можно использовать повторно.
Я использую Botpress.
<html >
<head>
<style>
#bp-widget {
height: 37.5em;
width: 18.75em;
}
#bp-widget.bp-widget-web.bp-widget-widget {
display: none;
}
#my-logo {
position:fixed;
cursor: pointer;
width: 6.375em;
height: 6.375em;
top: 80%;
left: 90%;
}
#blind_button {
position: fixed;
opacity: 0;
top: -100vh;
}
</style>
</head>
<body id="opened_bot">
<h1>Test Script</h1>
<a id="blind_button" target="_blank" href="http://some/URL">Bouton parler au chatbot</a>
<img id="my-logo" title="Cliques sur le logo pour commencer la conversation" src="https://other/URL"/>
<script src="https://myProject/api/botpress-platform-webchat/inject.js"></script>
<script>
window.botpressWebChat.init({
host: 'https://myProject',
hideWidget: true,
botName: 'Super Bot',
botAvatarUrl: 'https://this.gif',
botConvoTitle: 'Super Bot',
botConvoDescription: "...",
backgroundColor: '#ffffff',
textColorOnBackground: 'black',
foregroundColor: '#3B5998',
customStylesheet: 'https://myProject/wp-includes/css/styleChat.css'
})
</script>
<script>
document.body.onload = () => {
window.botpressWebChat.sendEvent({ type: 'show' });
};
document.getElementById('my-logo').addEventListener('click', () => {
window.botpressWebChat.sendEvent({ type: 'show' })
});
</script>
</body>
</html>