Show/Hide Widget
Learn how to control widget visibility
Overview
You can programmatically control when the Molin AI widget is shown or hidden on your pages. This is useful for:
- hiding the widget on specific pages (e.g. checkout, terms of service)
- showing the widget only after certain conditions are met
- managing widget visibility inside iframes
Default Behavior
By default, the widget:
- is visible on all pages where it’s installed
- is hidden when loaded inside an iframe
- remembers its open/closed state between page navigations (on desktop only)
Customizing visibility
Option 1. Using settings JSON (recommended)
Simply include your settings in a <script>
tag, placed anywhere inside the <head></head>
section of your website:
If you set hidden: true
, the widget launcher will be hidden when it loads, in all cases, on both mobile and desktop.
If you set hidden: false
, the widget launcher will be visible when it loads, in all cases, on both mobile and desktop, even if the page was loaded inside an iframe.
If you do not set hidden
to any value, then the default behavior explained above will apply.
Option 2. Programmatically using JavaScript (advanced)
The widget exposes these methods:
window.Molin
is only available after the widget script has fully loaded. We use various algorithms to delay the loading of the script to minimize impact on your website’s performance.
The widget’s visibility methods are only available after the widget script has loaded. Always check that window.Molin
exists before calling methods:
Examples
Hide on specific pages
Either implement some logic on your backend that controls the value assigned to the hidden
property inside window.molinSettings
:
or use JavaScript to hide the widget on specific pages:
Show chat window on button click
You can add a “Chat with us” button to your page that opens the chat window when clicked: