2019-12-03 18:03:25 +00:00
|
|
|
<template>
|
|
|
|
<div class="app-container chatbot-container">
|
|
|
|
<h1>Chatbot Joe</h1>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'Chatbot',
|
|
|
|
components: { },
|
|
|
|
data() {
|
2019-12-10 15:30:27 +00:00
|
|
|
return {}
|
2019-12-03 18:03:25 +00:00
|
|
|
},
|
|
|
|
mounted: () => {
|
2020-01-02 17:12:16 +00:00
|
|
|
window.addEventListener('message', this.messageEventHandler, false)
|
|
|
|
|
2019-12-10 16:07:20 +00:00
|
|
|
let host = 'https://joinbot.tk/bot'
|
2019-12-10 16:48:29 +00:00
|
|
|
let stylesheetdir = '/bot/assets/modules/channel-web/chat.css'
|
2019-12-10 15:49:46 +00:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
host = 'http://localhost:3000'
|
2019-12-10 16:48:29 +00:00
|
|
|
stylesheetdir = '/assets/modules/channel-web/chat.css'
|
2019-12-10 15:49:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
window.botpressWebChat.init({ host: host, botId: 'joinbot', enableReset: false,
|
2019-12-10 15:30:27 +00:00
|
|
|
enableTranscriptDownload: false,
|
|
|
|
hideWidget: true,
|
2019-12-10 16:48:29 +00:00
|
|
|
extraStylesheet: stylesheetdir,
|
2019-12-26 11:45:29 +00:00
|
|
|
botName: 'Jo'
|
2019-12-10 15:30:27 +00:00
|
|
|
})
|
2019-12-03 18:03:25 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
window.botpressWebChat.sendEvent({
|
|
|
|
type: 'show',
|
|
|
|
channel: 'web'
|
|
|
|
})
|
|
|
|
// window.botpressWebChat.sendEvent({ type: 'message', text: 'Hallo!' })
|
|
|
|
}, 1500)
|
|
|
|
},
|
2019-12-10 15:30:27 +00:00
|
|
|
beforeDestroy: () => {
|
2020-01-02 17:12:16 +00:00
|
|
|
window.removeEventListener('message', this.messageEventHandler, false)
|
|
|
|
|
2019-12-10 15:30:27 +00:00
|
|
|
document.getElementById('bp-widget').parentElement.removeChild(document.getElementById('bp-widget'))
|
|
|
|
},
|
2019-12-03 18:03:25 +00:00
|
|
|
methods: {
|
2020-01-02 17:12:16 +00:00
|
|
|
messageEventHandler(event) {
|
|
|
|
console.log('Message handler')
|
|
|
|
console.log(event.message)
|
|
|
|
}
|
2019-12-03 18:03:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.chatbot-container {
|
|
|
|
margin: 50px;
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
.document-btn {
|
|
|
|
margin-left: 50px;
|
|
|
|
display: block;
|
|
|
|
cursor: pointer;
|
|
|
|
background: black;
|
|
|
|
color: white;
|
|
|
|
height: 60px;
|
|
|
|
width: 200px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
line-height: 60px;
|
|
|
|
font-size: 20px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<style>
|
|
|
|
#bp-widget {
|
|
|
|
bottom: 0px;
|
|
|
|
right: 0px;
|
2019-12-10 15:30:27 +00:00
|
|
|
width: 70%;
|
|
|
|
height: 100% !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
#bp-web-widget {
|
|
|
|
width:100%;
|
|
|
|
height:100%
|
2019-12-03 18:03:25 +00:00
|
|
|
}
|
|
|
|
</style>
|