This widget is and is subject to change in minor versions.
Signature
Import
JavaScript
About this widget
Use<PromptSuggestions> 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
Props
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 | () => object
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.(hits: Hit[]) => unknown[]
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 prop is ignored when you set context.JavaScript
(items: string[], metadata: { query, results }) => string[]
A function that receives the generated suggestions and returns the list to display.
The second argument contains the current
query and results.JavaScript
(prompt: string, helpers: { sendToChat }) => void
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
(props) => JSX.Element
A component to replace the default pills layout with custom markup. The component 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
(props) => JSX.Element | false
A component to replace the default header. Set it to
false to hide the header. It receives the classNames and translations objects.JavaScript
Partial<PromptSuggestionsClassNames>
The CSS classes you can override and pass to the widget’s elements.
It’s useful to style widgets with class-based CSS frameworks like Bootstrap or Tailwind CSS.
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
Partial<PromptSuggestionsTranslations>
A dictionary of translations to customize the UI text and support internationalization.
headerTitle. The title displayed in the header.
JavaScript
React.ComponentProps<'div'>
Any
<div> prop to forward to the root element of the widget.JavaScript
Hook
Use theusePromptSuggestions Hook to build a fully custom UI. It accepts the same connector props (agentId or transport, configurationId, context, transformHits, transformItems) and returns:
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. Returnstrueif 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 thedisabledattribute on your suggestion buttons.
JavaScript