How to hide the show/hide chat widget button? I am making my own button

Is there a way to hide the default show/hide chat widget button. I want to replace it with another button that triggers on click:

window.HubSpotConversations.widget.open();

window.HubSpotConversations.widget.close();

An approach that I’ve tried is to access the iframe elements to hide it but its not possible because of xss issue.

Is there any way for this? Thanks

Hey @JLanda7, thank you for posting in our Community!

To hide the default show/hide chat widget button in HubSpot Conversations and replace it with your own custom button, you can use HubSpot’s JavaScript API to manage the widget. You don’t need to directly manipulate the iframe elements, which can lead to cross-site scripting (XSS) issues.

To our top experts @DanielSanchez and @Anton do you have any recommendations for @JLanda7 matter?

Thank you,

Pam

What properties specifically can we use to hide/customise the button from the JavaScript API? is there detailed documentation on this?

Thanks

I solved it by hiding to the bottom via css:

.widget-align-right#hubspot-messages-iframe-container{

bottom: -80px !important;

}

@PamCotton is right, you can manage the chat widget without needing to use CSS.

@JLanda7 @MCroft9, here are the JavaScript code snippets to control the chat widget.

You can disable the initial load of the chat widget with this JavaScript code.

<script>window.hsConversationsSettings = {loadImmediately: false,};</script>

Then to load the chat widget from a button, use this JavaScript code.

window.HubSpotConversations.widget.load();

Once the chat widget is loaded, you can further open or close the widget with this JavaScript code.

window.HubSpotConversations.widget.close();window.HubSpotConversations.widget.open();

For more information about using the Hubspot chat widget, see the Hubspot developer documentation here:

Good luck!