SpecOS SpecOS icon Documentation

Widget Integrations

Widget Integrations provide a way to integrate Spec-Right's powerful product search and discovery features directly into your own website or application. By adding a small snippet of code, you can render an interactive widget that allows your users to find the products they need without leaving your site.

How it Works

The widget is a client-side component that you embed on your page. It communicates with Spec-Right's API to fetch product information and perform searches. To do this securely, it must be initialized with an App ID.

Core Features

  • Seamless Integration: The widget is designed to be easily embedded into any website.
  • Powerful Search: Gives users access to Spec-Right's search capabilities.
  • Configurable UI: You can customize certain aspects of the widget's appearance and behavior.

Configuration

Widget configuration is tied to its App ID and is managed from your Spec-Right dashboard. This allows you to make changes to your widget's behavior without needing to change the code on your site.

Configurable options include:

  • Empty State: What to display when the widget is first opened. This can be configured to one of the following modes:
    • specright_logo: Displays the Spec-Right logo.
    • specright_ferguson: Displays a combined Spec-Right and Ferguson logo.
    • blank: Displays nothing.
    • text: Displays a custom text message, which you can set.
  • Buttons: You can define a set of up to four "quick action" buttons with predefined messages to guide your users. For each button, you can configure:
    • Label: The text that appears on the button.
    • Message: The search query that is sent when the button is clicked.
    • Icon: A decorative icon for the button.
    • Active State: You can activate or deactivate buttons. Only active buttons are displayed.
    • Slot: You can assign each active button to a slot from 1 to 4 to control the display order.

Getting Started

  1. Create an App ID: Go to your Spec-Right dashboard and create a new App ID.
  2. Whitelist Your Domain: Add the domain of the website where you will be embedding the widget to the App ID's domain whitelist.
  3. Configure Your Widget: Customize the widget's settings, such as the empty state and action buttons.
  4. Embed the Code: Copy the provided code snippet and paste it into your website's HTML. Make sure to include your App ID.

Integration Example

You can integrate the widget into your website by adding a single script tag. The widget will appear as a floating button in the bottom-right corner of your page that expands into a full chat interface when clicked.

<script src="https://specrightai.com/widget-loader.js" data-api-key="sr_YOUR_APP_ID"></script>

Replace sr_YOUR_APP_ID with your public App ID.

Widget Behavior

  • Initial State: The widget appears as a small, circular floating button (80px × 80px) positioned in the bottom-right corner of the page
  • Open State: When clicked, the widget expands into a chat panel with responsive dimensions:
    • Desktop: 560px wide, full viewport height
    • Mobile: Full viewport width (100vw), full viewport height
    • The panel is positioned flush against the right edge with proper margins
  • Non-Intrusive: The small button state doesn't interfere with page interactions or block content
  • Persistent: Chat conversations remain active when the widget is closed and reopened

See also: App IDs