botpress / solutions

List of Botpress templates / examples for common problems. Kick start your chatbot development with these ready-to-go custom modules, actions, hooks, and tools!
https://botpress.com
60 stars 27 forks source link

hide chat is not working #62

Open chaitanya71998 opened 2 years ago

chaitanya71998 commented 2 years ago

Greetings, I was using hide-chat in a botpress project. I created a flow to make composer hide and should be visible only when required. Sometimes its working fine but and not working sometimes, especially when I am using for mobiles. Not knowing why is this happening. Can I know what is the issue here and how to solve it

here is the link to the flow I created with hide-chat module https://drive.google.com/drive/folders/1a1uCL-gvzlbgWwnpfg8qZmKWVJtr366Y?usp=sharing

also what are these conditions isBotMessage && isLastGroup we are using for, can we remove these conditions, if removed will they cause any issue?

if (isBotMessage && isLastGroup) {
      composer.setHidden(hidden)
    }

Thanks in advance

bassamtantawi-botpress commented 2 years ago

Hi @chaitanya71998 ,

Do you want to hide only the composer or minimize the whole bot?

chaitanya71998 commented 2 years ago

Hi @bassamtantawi-botpress yeah wanted to hide composer

ptrckbp commented 2 years ago

The conditions are used to make sure that if the chat is restored (user opens and closes window), and there are more than one component in the message list, just the one from the last group gets executed (race condition). This is due to the component executes code onMount.

We aren't sure why it's not working for you sometimes. You might want to put a bunch of console.logs and try it out with different screen sizes in your browser. If the problem only happens on mobile, you can create an api endpoint using https://requestbin.com/ and call the endpoint when the state changes in the component. If you manage to write code that reproduces the issue reliably, let us know.

chaitanya71998 commented 2 years ago

Hi @ptrckbp can you explain more clearly i didn't understand the use of condition, will it cause problem if we remove conditions?

ptrckbp commented 2 years ago

The conditions are used to prevent a race condition, so if you remove them, you will occasionally encounter issues. Are they the ones causing issues with mobile?

chaitanya71998 commented 2 years ago

No, before removing condition this issue is coming.