Appearance
Lifecycle
The Mathew chatbot runs functions called lifecycle hooks every time something happens in it (e.g. when the chatbot is opened, when a message is sent, etc.).
You can use these hooks to run your own code at these times.
Registering lifecycle hooks
Lifecycle hooks are registered in the startChatbot
function.
javascript
import { startChatbot } from '@adaptical/mathew-chatbot'
const chatbotRoot = document.querySelector('#app')
const chatbotOptions = {}
const lifecycleHooks = {
onOpenChatbot: () => console.log('Chatbot opened'),
onCloseChatbot: () => console.log('Chatbot closed'),
}
startChatbot(chatbotRoot, chatbotOptions, lifecycleHooks)