Docs
widgets
Search

Search Widget

Integrate our powerful search widget into your website using the search nodes. This widget leverages AI driven search technology to provide more accurate and relevant search results by understanding the context and meaning of the queries rather than just matching keywords. Now, you can offer this advanced search functionality directly on your site.


img.png

Steps to Integrate the Search Widget

Follow these steps to integrate the search widget into your site using the provided CDN script:

1. Whitelist Your Domains

To use the Search Widget, you need to whitelist the domains where you will deploy the widget. This ensures that the widget is only used on approved domains.

  • Update your searchTrigger settings to include the domains you plan to use.
  • This configuration is typically done through your admin panel or server settings.

2. Include the CDN Script and Configure the Widget

Add the CDN script to your HTML file and configure the widget using the provided options.

Here’s how to include the CDN script and configure the widget:

<script async src="https://widget.lamatic.ai/search/index.js" onload="loadSearchDialog()"></script>
 
<script>
  // Set Lamatic config
  var SEARCH_DIALOG_CONFIG = {
    apiUrl: 'https://example.lamatic.workers.dev', // The base URL of your project endpoint (REQUIRED)
    workflowId: 'demo-workflow-id', // The workflow ID where you have set up your search configuration (REQUIRED)
    customButtonId: 'searchButton', // The ID of a custom button that triggers the search dialog
    primaryColor: '#007bff', // The primary color for the search widget (HEX value only)
    titleTextColor: '#007bff', // The color of the title text in the search results
    subTitleTextColor: '#666', // The color of the subtitle text in the search results
    width: '60vw', // The width of the search dialog box
    showNavHelperText: true, // Whether to show helper text for navigation within the search results
    showEscapeHelperText: true, // Whether to show helper text for escaping the search dialog
    searchPlaceholderText: 'Search our knowledge base...', // The placeholder text for the search input
    searchDebounce: 200, // The debounce time (in milliseconds) for search input
    linkTarget: "_blank", // The target attribute for links in search results
    breakpoint: 768, // The breakpoint (in pixels) for responsive design
    fontFamily: "Arial" // The font family to be used in the search widget
  };
 
  // Load Lamatic dialog
  function loadSearchDialog() { new SearchDialog(SEARCH_DIALOG_CONFIG) };
</script>

Props

Below is the documentation for the props used in the search widget configuration:

ParameterTypeDescription
apiUrl (required)stringThe base URL of your project endpoint.
workflowId (required)stringThe workflow ID where you have set up your search configuration.
customButtonIdstringThe ID of a custom button that triggers the search dialog. This prop is optional, and if not provided, the default button will be used.
primaryColorstringThe primary color for the search widget, used for the main elements like the search button. Accepts ONLY HEX VALUES.
titleTextColorstringThe color of the title text in the search results. Accepts any valid CSS color value.
subTitleTextColorstringThe color of the subtitle text in the search results. Accepts any valid CSS color value.
widthstringThe width of the search dialog box. This can be set using any valid CSS width value (e.g., 50vw, 600px).
showNavHelperTextbooleanDetermines whether to show helper text for navigation within the search results. Set to true to display the text, or false to hide it.
showEscapeHelperTextbooleanControls the visibility of the escape helper text, which instructs users how to close the search dialog. Set to true to show, or false to hide.
searchPlaceholderTextstringCustom text displayed as a placeholder in the search input field, guiding users on what to type.
searchDebouncenumberThe debounce time in milliseconds for API calls. This helps in reducing the number of API requests by waiting for the user to stop typing for the specified time.
linkTargetstringDetermines how the search result links will open. Use _self to open links in the same tab, _blank to open in a new tab, etc.
breakpointnumberThe pixel width at which the widget adjusts its layout for smaller screens. This value defines the breakpoint for responsive design.
fontFamilystringThe font family to be used in the search widget. Provide any valid CSS font family name (e.g., Verdana, Arial, Helvetica).

Was this page useful?

Questions? We're here to help

Subscribe to updates