@brainfish-ai/web-widget
v1.3.1
Published
Brainfish Widgets Manager
Downloads
2,062
Readme
Brainfish In-App Widget
This package provides a simple way to integrate a Brainfish in-app widget in your website or web application. It supports the standard style, and slide-in popup.
Installation
npm install @branfish-ai/web-widget
Directly in your HTML
<script type="module">
import Brainfish from "https://cdn.jsdelivr.net/npm/@brainfish-ai/web-widget@latest/dist/web.js"
Brainfish.Widgets.init({ widgetKey: "your-key" });
</script>
<button class="brainfish-trigger-button" onClick="Brainfish.HelpWidget.open('brainfish-trigger-button')">Help</button>
<!-- The widget will emit events when it opens and closes. You can listen to these events by adding the following code to your website: -->
<script>
// set up the abort controller
const controller = new AbortController();
// get the signal
const { signal } = controller;
// For close event: (onBrainfishHelpWidgetClosed)
window.addEventListener('onBrainfishHelpWidgetClosed', yourClosedHandlerFunction, { signal });
// For opened event: (onBrainfishHelpWidgetOpened)
window.addEventListener('onBrainfishHelpWidgetOpened', yourOpenedHandlerFunction, { signal });
</script>
<script>
// abort the event listeners when the widget is no longer needed
controller.abort();
</script>