Skip to main content
This widget is and is subject to change in minor versions.
For more information, see Agent Studio.
Signature

Import

About this widget

Use the promptSuggestions widget to display AI-generated prompt suggestions as clickable pills. An Agent Studio agent generates the suggestions from the current search context: the query, the active filters, and a sample of the results. When users click a suggestion, the widget opens the chat widget on the same index and submits the prompt. The widget fetches suggestions when it mounts, and fetches them again when the query, filters, or results change. Suggestions stream in progressively, and a skeleton placeholder shows while the first suggestions load. These suggestions differ from the follow-up prompt suggestions that appear after each agent response inside the chat. See also: Agent Studio
The default click behavior needs a chat widget on the same index. Without one, the widget logs a development warning when users click a suggestion. To handle clicks yourself, use onSuggestionClick.

Examples

JavaScript

Options

string | HTMLElement
required
The CSS Selector or HTMLElement to insert the widget into.
string
required
The identifier of the prompt configuration that generates the suggestions. Create prompt configurations in the Components section of your agent in the Agent Studio dashboard.
JavaScript
string
The unique identifier of the agent to connect to. You can find the agentId in the Agent Studio dashboard. Required unless you provide a custom transport.
JavaScript
object
A custom transport object to handle the communication between the widget and your own backend. When set, agentId and the search client credentials are ignored.The object accepts the following properties:
  • api (string). The endpoint URL to send suggestion requests to.
  • headers (Record<string, string>). Headers to send with each request.
  • prepareSendMessagesRequest (function). Transforms the request body before it’s sent. Receives the body object and returns { body }.
JavaScript
object | function
Explicit page context to send to the agent instead of the automatically extracted search context.By default, the widget sends the current query, the active filters, and a sample of the results. Set context to replace this with your own data, for example the product record on a product detail page. context can be a static object or a function that returns an object for each fetch.When you set context, the widget fetches suggestions even without search results, and transformHits is ignored.
The widget sends context to the agent in plain text. Don’t put secrets, access tokens, or personally identifiable information you don’t intend to share with the model in this field.
function
A function that receives the current results and returns the subset (or reshaped objects) sent to the agent as context. By default, the widget sends the first five hits with internal metadata (attributes prefixed with _) removed. This option is ignored when you set context.
JavaScript
function
A function that receives the generated suggestions and returns the list to display. The second argument contains the current query and results.
JavaScript
function
A function to override the default click behavior (sending the prompt to the chat widget). It receives the clicked prompt and a helpers object with sendToChat, so you can run custom logic (for example, analytics) and then fall through to the default behavior.
JavaScript
object
The templates to use for the widget.
JavaScript
object
The CSS classes you can override:
  • root. The root element of the widget.
  • header. The header element.
  • headerTitle. The header title element.
  • suggestion. Each suggestion pill.
  • skeleton. The skeleton container shown while loading.
  • skeletonItem. Each skeleton placeholder pill.
JavaScript
object
A dictionary of translations to customize the UI text and support internationalization.
  • headerTitle. The title displayed in the header.
JavaScript

Templates

You can customize parts of a widget’s UI using the Templates API. Each template includes an html function, which you can use as a tagged template. This function safely renders templates as HTML strings and works directly in the browser—no build step required. For details, see Templating your UI.
The html function is available in InstantSearch.js version 4.46.0 or later.
function
A template to replace the default pills layout with custom markup. The template owns the full rendering: the list, the loading state, and the click handlers. It receives:
  • suggestions. The generated prompt strings.
  • isLoading. Whether the widget is fetching suggestions.
  • onSuggestionClick. The click handler for a suggestion.
  • isChatBusy. Whether the chat widget is streaming a response.
JavaScript
function | false
A template to replace the default header. Set it to false to hide the header. It receives the classNames and translations objects.
JavaScript

HTML output

HTML
While the first suggestions load, the widget renders skeleton placeholders instead of the pills:
HTML

Connector render state

Use connectPromptSuggestions to build a fully custom UI. Its render state exposes:
  • suggestions (string[]). The generated prompt strings.
  • isLoading (boolean). Whether the widget is fetching suggestions.
  • onSuggestionClick ((prompt: string) => void). The default click handler, which sends the prompt to the chat.
  • sendToChat ((prompt: string) => boolean). Sends the prompt to the chat widget on the same index, with the page context attached as per-turn context. Returns true if the chat received it.
  • refresh (() => void). Fetches new suggestions for the current search state.
  • isChatBusy (boolean). Whether the chat widget is streaming a response. Use it to set the disabled attribute on your suggestion buttons.
JavaScript
Last modified on August 5, 2026