Before you begin
- You need an Agent Studio agent with an Algolia Search tool connected to the index that your search page uses. The result card uses the same agent as your chat, so the agent’s prompt and tools apply.
- You need an InstantSearch.js or React InstantSearch search page. For the base setup, see Integrate Agent Studio.
- To let users continue in chat, your page needs the
chatwidget with the same agent ID as the card.
How the result card works
- Users search. The widget adds the rule context
agent-studio-result-card-AGENT_IDto the search request. - If an activation rule matches the search, the search response tells the widget to show the card. Without a matching rule, the card stays hidden.
- If the query has at least two words, the widget sends the query, the active filters, and the first five hits to your agent as per-turn context. It asks which of these results the agent recommends and why.
- The card shows a skeleton placeholder until the first text arrives, then streams the answer.
- The widget only sends another request when the query, the filters, or the first five hits change. Going to another page of results doesn’t send a request.
Set up the result card
You set up the result card once for each agent. Agent Studio creates a base set of activation rules for you.1
Open the Result Card component
In the Agent Studio dashboard, open your agent, go to the Components tab, and select Result Card.
2
Select an index and enable the card
Select the Index that your search page queries, then turn on Enabled.
3
Optional: configure follow-up suggestions
Use Follow-up prompt suggestions to control whether the agent suggests follow-up prompts.
When it’s on, the agent suggests follow-up prompts that users can select to continue in chat.
This setting also applies to your chat.
4
Review the activation rules
Activation Rules control which searches show the card.
The default Result Card rule applies to this agent and matches queries that contain any of these words:
for, is, choose, should, recommend, versus, best, which, what, how, vs, compare, difference, between, and suggest.
These words signal questions that call for a recommendation, such as “best laptop for gaming”.To change when the card shows, edit the default rule or select Add Rule.
For each rule, you can set:- Name.
- Enabled.
- One or more conditions on the Query, Filters, or Context.
- Optional: a start and end date in From and Until.
agent-studio-result-card-AGENT_ID.
Keep it in the Context condition to limit a rule to this agent.
Select a custom context instead if your integration supplies its own.5
Test in the live preview
In the Live preview panel, enter a test query of at least two words, then select Generate preview.
The preview also shows whether your activation rules match the query.
6
Add the widget to your search page
Select the code icon next to Enabled to open Integration.
It generates the code for your agent and index in React InstantSearch or InstantSearch.js.
Place the widget before your hits, in the same InstantSearch index, and use the same agent ID in every widget that connects to the agent.
7
Search with at least two words
Open your page and search with a query that matches an activation rule.
A one-word query keeps the card hidden.
Continue in chat
When achat widget with the same agent ID is on the same index, the card shows:
- A Continue in chat button.
- Up to two follow-up suggestions from the agent, when Follow-up prompt suggestions is on.
chatTrigger widget.
Without a matching chat widget, the card hides these actions.
Know how users interact with the card
- Users can collapse the card to its header. The answer keeps generating, and the card stays collapsed for later searches until users restore it.
- The card clips long answers and shows a Show more button to reveal the full text.
- If the request fails, the card shows a Retry button.
- If the answer completes without any text, the card doesn’t render.
Customize the card
The widget lets you change the card without building your own UI:- Rename the title and buttons with
translations. The title defaults to “AI Overview”. - Restyle the card with
cssClassesin JavaScript orclassNamesin React. - Replace the markup with
templates.layoutin JavaScript orlayoutComponentin React. - Build a fully custom UI with the
connectResultCardconnector in JavaScript or theuseResultCardHook in React.
Send requests to your own backend
By default, the widget sends requests to Agent Studio. To send them to your own backend, pass atransport option.
To add headers or query parameters to Agent Studio requests, pass requestOptions.
You can’t use both options together.
The agentId stays required with a custom transport, because the widget derives its rule context from it.