Yes, however I don’t understand how to make the bo...
# 🌎general
c
Yes, however I don’t understand how to make the bot open and talk when the website loads
f
Hey @cool-gold-3015 , You need two parts, one is the open up action itself: https://botpress.com/docs/cloud/channels/webchat/#trigger-widget-actions
Copy code
window.botpressWebChat.onEvent(
        function (event) {
          if (event.type === 'LIFECYCLE.LOADED') {
            window.botpressWebChat.sendEvent({ type: 'show' })
          }
        },
        ['LIFECYCLE.LOADED']
      )
And this in your studio:
I hope that it is clear
c
So where does the open up action go?
In the website Html?
f
Yes on the website HTML
Keep me posted please, did it work or not 🙂
c
thank you Bassam for taking over !
w
woow
thanks guys
it works
this is a good one 🙂
f
@white-kangaroo-57225 anytime 😉
@crooked-van-25152 one team 🙂
c
Yesss! 🙌
f
This would be a super useful feature. The ability to control both, whether the chat pops up proactively or not and if it does pop up, after how many seconds. I'll add it to the feature requests
c
Cheers @fresh-easter-64955 !
Make sure people upvote it.
f
@User do we have a tutorial about this?
c
Is there anyone brave enough to create a quick tutorial on this? 😍
f
😄
c
Trying it now
So i put this in the body of my HTML code?
@famous-jewelry-85388 Im having trouble
f
Perfect! troubles mean we are moving forward 😄
tell me what is the trouble?
c
Got your code to work @famous-jewelry-85388 I can do a short tutorial in a few hours @cool-gold-3015. May I know if you are using Wordpress + elementor for your website or some other platform?
c
Framer
Thanks I will have a look
f
@careful-keyboard-68830 🔥
c
Great it should work the same 🙂
f
@cool-gold-3015 Keep us posted if it worked for you or not
b
@cool-gold-3015 Hard to tell exactly what your problem is so this is a bit of a shot in the dark. It may work either way but I would put this in either the header or footer, not the body. And did you enclose this in tags? window.botpressWebChat.onEvent( function (event) { if (event.type === 'LIFECYCLE.LOADED') { window.botpressWebChat.sendEvent({ type: 'show' }) } }, ['LIFECYCLE.LOADED'] )
An alternate method that might be necessary depending on your situation: //Open the chatbot window as soon as the page finishes loading window.addEventListener("load", function() { //Open the chatbot window before triggering the chatbot greeting window.botpressWebChat.sendEvent({ type: "show" }); //Trigger the chatbot initial greeting, but give it some time after the "show" event to load first //TODO: Detect when the bot is ready in a tight loop to improve reliability and load speed setTimeout(function() { window.botpressWebChat.sendPayload({ type: "trigger", payload: { } }); }, 1500); });
Another thing to try, add defer to your script tag
43 Views