https://discord.gg/botpress logo
Problem with visibitly on the website
# 🤝help
i
we’re seeing an issue with one of our clients: their chatbot isn’t showing up reliably. During testing it sometimes only appears on the 6th or 7th attempt, even across different devices and browsers. For us as well, it fails to load every few tries, without any clear pattern. Any idea what could be causing this? Maybe something related to privacy or cookie settings?
w
hi there! any chance it could be an embed issue?
did you modify the code in any way?
if you could paste the code used in the embed here i'd appreciate it
i
i added a auto open feature but the issue was there already before
i just copied the given botpress snippet
w
and where did you paste it?
l
loading up your bot and trying on my end in the mean time!
i
we did not implement it but we sent them the documentation so i guess its in the part like mentioned in the docs
thank you!
w
but that only happens with that one client, right:
the issue probably lies in the implementation
i think double checking theirs is a good first step
if you could link me the website as well so i could take a look at the widget
i
yes we didnt have any other issues. also when i tried it it worked for me but our contact partner mentioned that the whole team had issues
Was the conversation not starting at all?
i
the icon of the bot was not visible at all in the first place but when they refreshed the page on the fith or sixt time it showed up
for me it works fine i guess for you aswell if you can use the bot
just trying to figure out if this is a problem with botpress or like @wide-umbrella-5226 mentioned with the implementation
l
is the bot meant to be present here:? https://www.biobote-emsland.de/
i
yes
w
i think it's embedded in the head
and not body
i'm fairly confused actually the code is pretty unreadable
give me a few minutes
l
yeah seems to be implementation forsure
i
okay thank you in advance
w
yeah there are several implementation errors
since the scripts are set as plain text, they wait for cookies to be accepted to run
but after they're accepted, 20250711123152-3G5TOHXV.js runs intantly
and it tries running window.botpress.init while window.botpress doesn't exist yet
so you should maybe run ``automatically to load the botpress window
and then keep the other script with the botpress initialization in the cookie scripts
i
how can i do that?
w
change the previous
<script data-type="text/javascript" data-src="https://cdn.botpress.cloud/webchat/v3.2/inject.js" type="text/plain" data-name="chatbot"></script>
to
<script type="text/javascript" src="https://cdn.botpress.cloud/webchat/v3.2/inject.js" data-never-block></script>
@icy-market-92637
i think your auto open function is drastically over-engineered as well
sorry not yours
theirs
i
thank you very much for your help just one question: how is it still possible that i and other people can acces the bot after accepting the cookies but for some its not working?
i will revise it thank you
w
well it's a bit of luck and a bit of computing power difference
it works if inject.js finishes running before window.botpress.init is called
if it doesn't load in time it fails
i
thank you very much for your support you helped a lot
w
you're welcome!!! please tag me if you need more help
@icy-market-92637 by the way i think your guy is on webchat v3.2
probably switch to v3.4 when you ccan
i
Hey @wide-umbrella-5226 Shen, quick update: The customer insists that no scripts be loaded before cookie consent, but at the same time wants us to move the entire handling (including auto-open and init logic) to our external scripts. Do you have any recommendations on how we can best solve this if inject.js and our init.js are both loaded simultaneously after consent and we still need to reliably intercept the race condition?
w
you can just not make it a race condition
Copy code
js
    window.addEventListener('load', function() {
        if (window.botpress) {
            window.botpress.init({
                // your configuration here
            });
        }
    });
you can add this event listener after the inject to only init the chat when it's loaded
w
I visited the site, and when I accepted the cookies, I could see the webchat, and it works
w
yes it works
but not to his client's specification
it works because i separated the chatbot injection and initiation
to erase the race condition
but his client said both scripts need to run only after cookie acceptance
which brings the race condition back since whatever cookie plugin is being used is pretty bad
w
when i denied the cookies, i couldn't see the webchat
w
yes because rejecting the cookie doesn't run the initiation
it's only injected
w
if i accept botpres cookie the webchat works
w
yes it works as it should
but his client wants a solution that doesn't run scripts if not accepted
the current way runs inject.js
possibly some gdpr monkey business
i
first of all thank you for your help. is it possible for me to change that in botpress or do i have to send them every time changes in the code Because like i said before we don't have direct access to the clients code
w
no unfortunately
the problem is your client's cookie extension
it runs a billion scripts at the same time then race condition starts
i don't think the initial inject.js breaks GDPR
but i don't know much about it either
i
we tried to offer them a solution where inject.js is seperated from the GDPR but they don't want to make that change i thought maybe like you said that i could change maybe some code so the race condition wouldn't happen at all
w
yeah you can, but only inside the website
i don't think you can solve this through botpress
i
but would there be a option to solve the problem of the race condition without neglecting the gdpr? with code we would implement on their website?
w
yes it's what i sent you
this
w
I did some checks, and the injector just creates
botpress-message-history
in the local storage with the initial value:` {"state":{"messageHistory":[]},"version":0}`
If this is classified as a technical or necessary cookie, you don't need to obtain cookie consent. All other cookies and information are created by init() and the conversation.
This is only valid if your client agrees 😔
Actually they have inject.js under cookie policy too
w
you can also just erase the race condition by calling the scripts in order
which that code snippet i send will hopefully do
i
okay thank you a lot also for providing the code i'll try to find a solution @white-nest-40686 thank you as well for your help
w
@icy-market-92637, I did nothing; Shen did the hard work.
i
@wide-umbrella-5226 Sorry to write to you again about this matter. Do you know if the race condition affects the proactive message, or is it restricted by the auto-open feature? https://cdn.discordapp.com/attachments/1442573330266980482/1469082534892798044/image.png?ex=69865d3a&is=69850bba&hm=8f4f781b517a67e1de95f29d033e6a9fb4ebae274d7ff9f1a1ceb0d2989fcb5b&
3 Views