Asset Enqueuing
Asset Enqueuing
To ensure the chatbot interface functions correctly and maintains its visual design, the Supervised AI Bots plugin automatically loads necessary stylesheets and JavaScript files onto your WordPress front-end. This process ensures that the popup behavior and the floating action button are available on any page where a bot is deployed.
Included Assets
The plugin enqueues two primary files:
custom-popup-style.css: Manages the visual presentation of the chatbot, including the fixed positioning at the bottom-right of the screen, the dimensions of the iframe container, and the styling for the "circle button" launcher.custom-popup-script.js: Contains the logic for thetogglePopup()andclosePopup()functions, allowing visitors to open and hide the chatbot interface.
Automatic Loading
These assets are registered and enqueued using standard WordPress hooks. You do not need to manually add <script> or <link> tags to your theme. The assets are optimized to load only when the plugin is active, ensuring minimal impact on site performance.
Customizing Styles
The plugin uses high-specificity CSS selectors to ensure the chatbot displays correctly regardless of your active theme. If you wish to override the default appearance (e.g., changing the button color or the popup height), you can add custom CSS to your theme's style.css or the WordPress Customizer targeting the following classes:
| Class Selector | Description |
| :--- | :--- |
| .circle-button | The floating round button used to open the chat. |
| .popup-container | The main wrapper for the chatbot iframe. |
| .iframe-container | The container specifically holding the chatbot's content. |
Example: Changing the Launcher Button Color
/* Change the floating button to a dark theme */
.circle-button {
background-color: #333333 !important;
box-shadow: 0px 4px 15px rgba(0,0,0,0.5);
}
Public JavaScript Interface
The plugin exposes global functions that can be called by other scripts on your page if you wish to trigger the chatbot programmatically:
| Function | Action |
| :--- | :--- |
| togglePopup() | Toggles the visibility of the chatbot between 'block' and 'none'. |
| closePopup() | Specifically forces the chatbot window to hide. |
Example: Custom "Contact Us" Button Trigger
<button onclick="togglePopup()">Chat with our AI</button>
Conflict Resolution
If your theme uses a "Lazy Load" or "Script Optimization" plugin, ensure that custom-popup-script.js is excluded from "defer" or "delay" settings if the chatbot launcher fails to respond to clicks.