Skip to main content
Prerequisites — before implementing AI Search, complete the Installation step on the JS Library page. The library must be loaded site-wide.
Kleep AI Search integrates a search component into your storefront, powered by Kleep’s AI algorithms. Product Feeds must be created and deployed before you start this integration — please confirm this with your Kleep representative before implementing.

What AI Search delivers

Kleep AI Search welcome page showing most-searched queries and trending searches

A welcome page with first insights on your catalogue — most-searched queries and trends

Kleep AI Search auto-suggestions dropdown appearing as the shopper types

Auto-suggestions appear as the shopper types. The complete list of suggestions is managed in the Kleep Search AI Dashboard — you can add, update, or remove them there.

Kleep AI Search product-list page with add-to-cart and wishlist actions

A product-list page with add-to-cart and wishlist actions

The product-list page supports two shopper actions through callbacks you implement:
Add a size to the cart if it’s in stock. When the shopper taps Add to cart on a size, your addToCart callback runs with the variant reference.
  • Input — an object { variant_ref }: the reference of the variant (size) to add to the cart
  • Action — add the reference to the cart like a regular add-to-cart
  • Output — none required
Checking if the variant is in stock is handled by Kleep — you don’t need to verify availability yourself.
Add / remove a product from the wishlist. When the shopper taps the heart icon, your toggleWishlist callback runs with the product reference.
  • Input — an object { product_ref }: the reference of the product being toggled
  • Action — if the reference is in the wishlist, remove it; if not, add it
  • Output — the updated wishlist, as an array of { product_ref } objects
Step 1: Create the container Add the div where the search component should be attached:
Step 2: Initialize with your credentials Call kleep.search.init with your account credentials:
init loads the search bundle and its stylesheet for you and returns a promise: always await it before calling renderBox or renderResult. It resolves to true on success and false if the credentials are invalid or the bundle failed to load.
anonKey and retailerId are provided by your Kleep representative during onboarding. companyId is still accepted in place of retailerId but is deprecated.
Step 3: Render the search box Call kleep.search.renderBox with the container ID (without the #) and your callback implementations:
By default the search box opens as an overlay over the page, with auto-suggestions, trending searches and the product list, so shoppers can search without leaving the page. Open it from your header’s search icon. Step 4: Render the results page (optional) When the shopper submits a search, send them to your search results page (for example /search?q=... — the URL is yours to choose, via onViewAll or onSearchSubmit) and render the results there:
The results page has filters (sizes included), sorting and pagination. Calling renderResult with an empty query while results are already displayed keeps them as they are.

Parameters & Callbacks

renderResult accepts query, gender, lang, getWishlistItems, toggleWishlist and addToCart with the same meaning.

Full example with callbacks

Check your dedicated ID Recap Table (provided by your Kleep representative) for the exact reference format to pass to these callbacks.

Take over the bag icon

Product cards also show a bag icon. By default it opens Kleep’s size picker; if your storefront has its own quick-add drawer, pass an addToCart callback to init and Kleep hands you the product instead:
The callback is read when the shopper taps the icon, so you can also register it after init. It is not called for sold-out products.

Search with a photo

When enabled for your account by Kleep, a camera button appears in the search bar: the shopper uploads a photo and gets visually similar products. Photo search needs your results page to be wired up (onViewAll or onSearchSubmit set). For a photo search, onViewAll receives an empty query and options.visualQueryId; add kleep_visual=<visualQueryId> to the results URL you open, and renderResult with an empty query shows the photo results.

Appearance and behaviour

Theme, layout, suggestions, filters, landing pages and custom CSS are managed by Kleep per retailer, and take effect without changes to your code. Ask your Kleep representative to adjust them. For example, the results page can be rendered as the search box itself (a “search box” layout) instead of the classic results grid.
On Shopify you don’t write this code: install the Kleep Search Box embed and follow the Shopify Search guide.
If you’re using AI Search on a Prestashop store, your Kleep webservice key needs a few extra GET permissions on top of the ones listed in the Prestashop integration guide: