Chat scroll vertical automatically

hello everyone

I designed a chat interface and did the animations on webflow natively using on page load. i want the chat to scroll automatically when new messages appear. can you pls suggest a code for that? thank you for your help


Here is my site Read-Only:

https://preview.com/preview/mabelles-ultra-awesome-site?utm_medium=preview_link&utm_source=designer&utm_content=mabelles-ultra-awesome-site&preview=a3416b477281c47b3ec6738f543b0ebe&pageId=6702d4ad3e204f6ee8635e93&locale=en&workflow=preview

You can achieve automatic scrolling in your Webflow chat interface by using JavaScript to detect when new messages appear and then adjusting the scroll position of the chat container. The script should observe changes in the message list and update the scrollTop property to ensure the latest message is always visible. You can implement this by using a MutationObserver to track new messages being added and then smoothly scroll the chat container to its maximum height. Make sure to apply this script within an embed block inside Webflow, targeting the correct class for your chat wrapper. If you need any help in the coding part would be happy to assist you.

hello thank you for your help. I’ve tried similar code but it didn’t work. Can you propose a code that i can integrate in webflow? thank you