How to make your chatbot shake when user receives ...
# 📖tutorials
g
Botpress Widget Shaking On Notifications ** @keyframes shake-animation { 0% { transform:translate(0,0) } 1.78571% { transform:translate(5px,0) } 3.57143% { transform:translate(0,0) } 5.35714% { transform:translate(5px,0) } 7.14286% { transform:translate(0,0) } 8.92857% { transform:translate(5px,0) } 10.71429% { transform:translate(0,0) } 100% { transform:translate(0,0) } }** * * **window.botpressWebChat.onEvent( (event) => { if (event.type === 'UI.OPENED') { document.querySelector('.bp-widget-widget').style.animation = 'none'; } else if (event.type === 'MESSAGE.RECEIVED') { document.querySelector('.bp-widget-widget').style.animation = 'shake-animation 3s ease infinite'; } }, ['UI.OPENED', 'MESSAGE.RECEIVED'] );**
What is in bold characters is what you must have in your code to make the chat icon shake
c
Pretty cool @glamorous-guitar-39983 ! If you have a quick video (loom or somethign) of the end result, it would be great to add it here before people dive into trying it out for their bot ✨ !
Thanks so much for sharing this tutorial with the community ❤️
g
c
You're going to make 100000 happy Discord members! @glamorous-guitar-39983 🥇
@ambitious-vr-9887 👀
g
But I do not have a sound coming with the shaking
This is why I like Botpress so much, wouldn't have been possible without knowing the event for receiving a message/opening the chat
a
Great work @glamorous-guitar-39983 🤩
p
Nice job!
b
Thats so neat! I'm gonna yoink this code! 😅 Thank you! ❤️
j
im using Wordpress where can i put this in ?
g
I don't know, I've never used Wordpress
s
Hi AbsorbingJet719! It seems there might have been a misunderstanding. Could you please describe the issue you're experiencing with the Botpress Webchat? This will help us assist you better.
g
I guess you only need to go to where you've integrated your script and add these lines of code: window.botpressWebChat.onEvent( (event) => { if (event.type === 'UI.OPENED') { document.querySelector('.bp-widget-widget').style.animation = 'none'; } else if (event.type === 'MESSAGE.RECEIVED') { document.querySelector('.bp-widget-widget').style.animation = 'shake-animation 3s ease infinite'; } }, ['UI.OPENED', 'MESSAGE.RECEIVED'] );
__I'm not sure this part can be done using javascript:__ @keyframes shake-animation { 0% { transform:translate(0,0) } 1.78571% { transform:translate(5px,0) } 3.57143% { transform:translate(0,0) } 5.35714% { transform:translate(5px,0) } 7.14286% { transform:translate(0,0) } 8.92857% { transform:translate(5px,0) } 10.71429% { transform:translate(0,0) } 100% { transform:translate(0,0) } }
ideally @jolly-policeman-82775 try to find a place where you can integrate html.
c
Could you help me with a question? How do I get this notification without having to initiate an interaction?
g
Let me know if this works
c
It didn't work it sends the notification after I open the chat the interaction occurs and the timeout message arrives. The notification needs to be in the chat as soon as I access the page, without having to open it and interact. But thanks for responding.
g
Im not sure but I think the fact that I didnt put the lifecycle loaded event before ui opened changes its effects
I know why it doesn't work
I can't query selector the bp-widget-widget, don't ask me why, I don't know
Actually I just thought about it
I've managed to make it work : now when you enter the website, the chatbot will automatically start shaking until you open the chatbot Code : Botpress Widget Shaking On Notifications @keyframes shake-animation { 0% { transform:translate(0,0) } 1.78571% { transform:translate(5px,0) } 3.57143% { transform:translate(0,0) } 5.35714% { transform:translate(5px,0) } 7.14286% { transform:translate(0,0) } 8.92857% { transform:translate(5px,0) } 10.71429% { transform:translate(0,0) } 100% { transform:translate(0,0) } } .bp-widget-widget { animation:shake-animation 3s ease infinite; } window.botpressWebChat.onEvent( (event) => { if (event.type === 'UI.OPENED') { document.querySelector('.bp-widget-widget').style.animation = 'none'; } else if (event.type === 'MESSAGE.RECEIVED') { document.querySelector('.bp-widget-widget').style.animation = 'shake-animation 3s ease infinite'; } }, ['UI.OPENED', 'MESSAGE.RECEIVED'] );
@cold-cartoon-97133 Does that work?
j
Works
hell yeah !
c
Hello, I haven't done the test yet on my project I'll make the change and let you know later thank you very much.
Thank you very much it makes the widget shake when accessing the page it somehow catches the users attention. 💯
g
No but you can make a post in #1111009377525186570 for this
a
I have the same problem - did you already find a solution for this?
c
I still don't have any information on how to resolve it. 🫤