How to setup frontend Chat API
This feature is available in selected plans only. At the moment it allows you to introduce your own callbacks for chat events. Two chat events are available:
- user message - handled by onUserMessage(userMessage:string)
- chatbot message - handled by onChatbotMessage(chatbotMessage:string)
In order to add such callbacks to your chatbot you need to add following script snippet to your html page:
<script>
window.aichatbotCallback = {
onUserMessage(message) {
console.log('onUserMessage', message);
/*your handler for the user message
....
*/
},
onChatbotMessage(message) {
console.log('onChatbotMessage', message);
/*your handler for the chatbot message
....
*/
},
}
</script>