takenet / blip-chat-widget

Widget to enable add the BLiP Chat in your web app or site
https://blip.ai
MIT License
60 stars 23 forks source link

Is this possible to use something like withEventHandler but for new messages? #56

Open robsonbbs opened 2 years ago

robsonbbs commented 2 years ago

Hi, I am using this widget without the traditional bubble button, instead, users use a custom button managed by my frontend and when they leave the chat I am doing something like this to hide the widget:

.withEventHandler(BlipChat.LEAVE_EVENT, () => {
      document.querySelector('#blip-chat-open-iframe').style.display = 'none'
})

The problem is: When my support team sends a new message if the user already closed the chat they need to tap my custom button again to check if there is any new message. What I would like to do is automatically reopens the chat after receiving a new message, this way I would call users' attention and they would know that there is a new message to them.

I know that I can use something like this to reopen the chat:

const toogleChat = () => {
    clientRef.current.toogleChat()
}

But how to trigger that once a new message was received?