Automatically opening live chat window with Rocket.Chat script


I have integrated the Rocket.Chat live chat script into my webpage. It automatically appears in the bottom-right corner without any issues.

However, I want it to be activated only by a button I added to my website. I’m achieving this with onClick, but now, due to the script being loaded, an additional click is required to open the live chat window.

I want to create a button that, when clicked, will automatically load the script and open a new chat window. How can I accomplish this?

Thanks in advance. Regards.


Add the following code after the Omnichannel script:

RocketChat(function() {