This widget is and is subject to change in minor versions.
Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
Useais-result-card to display an “AI Overview” card above your results.
The widget sends the query, the active filters, and the first five hits to an Agent Studio agent as per-turn context,
and asks the agent which of these results it recommends and why.
The answer streams into the card, and a skeleton placeholder shows until the first text arrives.
The card only shows when the search meets both conditions:
- A rule that matches the search sets
renderingContent.widgets.resultCard.enabledtotruein the search response. For more information, see Activate the card with a rule. - The query has at least two words.
ais-chat widget with the same agent-id is on the same index,
the card shows a Continue in chat button and up to two follow-up suggestions from the agent.
Both hand the card’s conversation to the chat and open it.
A suggestion is also sent to the chat as the next message.
If the chat is generating a response, the handoff doesn’t happen.
That makes the widget an entry point for the chat, so a page with both doesn’t also need an ais-chat-trigger widget.
Without a matching ais-chat widget, the card hides these actions and, in development, logs a warning.
Activate the card with a rule
The widget adds the rule contextagent-studio-result-card-AGENT_ID to every search,
where _ replaces any character in the agent ID other than letters, digits, _, and -.
Use this context as a rule condition to limit the rule to searches that include the widget.
To show the card, add a rule whose consequence sets renderingContent in its search parameters:
JSON
Examples
Vue
Props
string
required
The unique identifier of the agent to connect to.
You can find the agent ID in the Agent Studio dashboard.
It’s required even with a custom
transport, because the widget derives its rule context from it.
The card only hands its conversation to an ais-chat widget with the same agent-id.Vue
object
A custom transport object to send the card’s requests to your own backend instead of Agent Studio.
It has the same shape as the
transport prop of the ais-chat widget.
You can’t use it together with request-options.Vue
object
Request options to send with the built-in Agent Studio completion requests.
You can’t use it together with
transport.The object accepts the following properties:queryParameters(Record<string, string | number | boolean>). Query parameters to append to each completion request.headers(Record<string, string> | Headers). Headers to send with each completion request.
Vue
object
default:"{}"
The CSS classes you can override:
ais-ResultCard. The root element of the widget.ais-ResultCard-header. The header element.ais-ResultCard-headerTitle. The header title element.ais-ResultCard-continueButton. The Continue in chat button.ais-ResultCard-minimizeButton. The button that minimizes or maximizes the card.ais-ResultCard-body. The element that holds the answer and clips it.ais-ResultCard-loader. The skeleton placeholder shown while the answer loads.ais-ResultCard-message. Each answer message.ais-ResultCard-suggestions. The follow-up suggestions container.ais-ResultCard-expandButton. The button that shows or clips a long answer.
Vue
object
A dictionary of translations to customize the UI text and support internationalization.
headerTitle. The title displayed in the header. Defaults to"AI Overview".continueInChatText. The text of the button that hands the conversation to the chat. Defaults to"Continue in chat".minimizeLabel. The accessible label of the button that minimizes the card. Defaults to"Minimize".maximizeLabel. The accessible label of the button that maximizes a minimized card. Defaults to"Maximize".expandText. The text of the button that shows a clipped answer in full. Defaults to"Show more".collapseText. The text of the button that clips an expanded answer. Defaults to"Show less".retryText. The text of the retry button shown when the request fails. Defaults to"Retry".
Vue
Customize the UI
The slot to replace the whole card with custom markup.
The slot owns the full rendering, including every status and the retry and handoff actions.
When you use it, the
class-names and translations props don’t apply.Scopestatus: 'hidden' | 'loading' | 'streaming' | 'complete' | 'failed'. The card status. It’shiddenwhen no rule enables the card or when the query is shorter than two words. It’sloadingwhile the widget waits to send the request and until the response starts streaming.query: string. The query the answer is about.messages: UIMessage[]. The card’s conversation: the user message, then the assistant answer as it streams. The user message contains the full question that the widget sends to the agent. To display the query, usequeryinstead.error: Error | undefined. The error of the latest failed request. It’s only set whenstatusisfailed.suggestions: string[] | undefined. Follow-up suggestions sent by the agent with the answer.retry: () => void. Sends the request again.canContinueInChat: boolean. Whether anais-chatwidget with the sameagent-idis on the same index.continueInChat: (message?: string) => void. Hands the conversation to theais-chatwidget and opens it. When you passmessage, the chat sends it as the next message.expanded: boolean. Whether a long answer shows in full instead of clipped.setExpanded: (expanded: boolean) => void. Shows or clips a long answer.sendEvent: function. Sends an event to the Insights middleware.
Vue
HTML output
HTML
HTML
ais-ResultCard-minimizeButton button has aria-expanded="false" and the Maximize label, and the body, the expand button, the Continue in chat button, and the suggestions don’t render.
When users expand a long answer, or when the request fails, the body has the ais-ResultCard-body--expanded class.
When the answer is complete and isn’t clipped, the follow-up suggestions render after the body in a div with the ais-ChatPromptSuggestions ais-ResultCard-suggestions classes.