This widget is and is subject to change in minor versions.
Signature
Import
About this widget
Use thefilterSuggestions widget to display relevant facet filter suggestions powered by Algolia AI agents.
Suggestions are based on the current , refinements, and context.
Clicking a suggestion applies the corresponding filter.
To create this agent, choose the Filter suggestions template in the Agent Studio dashboard. The model used should be a faster, cheaper one (for example gpt-4.1-mini), as suggestions don’t require deep reasoning.
Example
JavaScript
Options
The CSS Selector or
HTMLElement to insert the widget into.The unique identifier of the agent to connect to. You can find the
agentId in the Agent Studio dashboard.JavaScript
A custom transport object to handle the communication between the widget and the agent. The API endpoint must be compatible with Vercel AI SDK 5.
JavaScript
Restrict suggestions to these facet attributes.
JavaScript
Maximum number of suggestions to display. Default: 3.
Debounce delay before fetching suggestions, in milliseconds. Default: 300.
Number of hits to send for context. Default: 5.
Transform the suggestions before rendering.
JavaScript
Custom templates for rendering:
- item: function to render each suggestion.
- header: function or
falseto customize or disable header. - empty: function to render when there are no suggestions.
JavaScript
The CSS classes you can override:
root: The root element of the widget.loadingRoot: The root element when loading.emptyRoot: The root element when empty.header: The header section.headerIcon: The sparkles icon in the header.headerTitle: The title text in the header.skeleton: The skeleton container when loading.skeletonItem: Each skeleton placeholder item.list: The list of suggestions.item: Each suggestion item.button: The button for each suggestion.label: The label text for each suggestion.count: The count for each suggestion.
JavaScript