close
Skip to main content
Add an Agent Studio shopping assistant to a product search app.

Before you begin

Make sure you have:
  • An Algolia account. Create one for free if you don’t already have one.
  • Node.js 20.19 or later.
  • React InstantSearch 7.34.0 or later. The Chat and ChatTrigger widgets require this version.
  • instantsearch.css 8.15.0 or later. Earlier versions don’t include the chat and AI Mode button stylesheets.
  • An API key from a supported LLM provider. For supported providers, see LLM providers.

Start from the product search app

This quickstart extends the product search quickstart. If you completed the quickstart, open that project and skip to Create your agent. To build the app from scratch instead of downloading it, follow the product search quickstart first, then return here.
1

Download the product search app

To download the app, run:
2

Add your Algolia credentials

In the Algolia dashboard, open the API Keys page and copy these values:
  • Application ID. Identifies your Algolia application.
  • Write API key. Used by the indexing script to update records and index settings.
  • Search API key. Used by the React app to query the index and call Agent Studio from the browser.
Create a .env.local file and add the values to it:
.env.local
Keep your Write API key secret. Don’t commit .env.local to version control or expose the write key in your app.
3

Index the sample products

Run the indexing script to create the quickstart-products index, add sample product records, and configure product_type as a facet.
You should see Successfully indexed products. in your terminal. In the Algolia dashboard, you can explore the quickstart-products index on the Browse page.

Create your agent

Create an agent that can search the quickstart-products index and answer shopping questions.
1

Open Agent Studio in the dashboard

  1. In the Algolia dashboard, select your application.
  2. On the left sidebar, select Generative AI > Get started.
  3. Under Agent templates, select Shopping assistant.
  4. On the Shopping assistant page, click Start setup.
2

Add an LLM provider

On the Connect your agent to an LLM provider page, select an existing provider or create a new one and enter the required credentials. For more information about supported providers and the required credentials, see LLM providers.
The Algolia Sandbox provider lets you test Agent Studio in the dashboard only. You need to use your own provider if you want to follow this quickstart.
Click Next: Data Access.
3

Connect an index

On the Define your agent’s knowledge page, select the quickstart-products index and click Save. Agent Studio automatically generates a description for the index.Click Next: Prompt.
4

Set up agent instructions

This quickstart uses the default template for a shopping assistant, with only a few adjustments.On the Guide your agent’s responses page, replace the following placeholders in the template:
  • Replace {{INSERT_BRAND}} with Algolia
  • Replace {{INSERT_INDUSTRY}} with fashion
  • Replace {{INSERT_LANGUAGE}} with English
  • Feel free to delete the line with the {{INSERT_COMPETITORS_LIST}} placeholder. This quickstart doesn’t need it, but leaving it in shouldn’t cause any issues.
Click Next: Entry Points.
5

Accept the default entry points, conversation features, and safety controls

  1. On the Configure how users find your agent page, accept the defaults and click Next: Conversation Features.
  2. On the Enhance your agent’s conversations page, accept the defaults and click Next: Safety Controls.
  3. On the Protect your agent’s usage page, accept the defaults and click Complete.
  4. In the confirmation dialog, click Start exploring. This opens the agent’s details page.
6

Test and publish your agent

On the agent’s details page, you can change all settings, including the agent prompt and safety controls. You can also test your agent with a few queries.When you’re ready to use the agent in your app, click Publish. In the confirmation dialog, click View integration help. Copy your agent ID.
You can also see the agent ID from the agent details view, by clicking on the Integration help icon.

Add chat to the product search app

Add the React InstantSearch chat widgets to the existing product search app.
1

Optional: upgrade your dependencies

If you just downloaded the code with npx gitpick, you can skip this step.If you completed the product search quickstart a while ago, upgrade the InstantSearch libraries:
The chat widgets require react-instantsearch 7.34.0 or later and instantsearch.css 8.15.0 or later.
2

Add your agent ID

Add your published agent ID to .env.local:
.env.local
3

Update the app

Replace src/App.tsx with the following code. The highlighted lines show changes to the product search app you prepared earlier.
src/App.tsx
Place Chat and ChatTrigger inside the same InstantSearch component as the search widgets.The product search app’s single ProductCard becomes two components, because search results and agent responses provide different props:
  • SearchProductCard renders search results with highlighting and snippets. Hits passes each record as a hit prop.
  • ChatProductCard renders products returned by the agent’s Algolia Search tool as plain text. The itemComponent prop of Chat passes each record as an item prop.
4

Update styles

Replace src/App.css with the following code. The highlighted lines show changes to the product search app you prepared earlier.
src/App.css
5

Test the chat

Start the development server:
If the server was already running, restart it. Open http://localhost:5173.
The app shows a product grid, a product type filter, and a search box with an AI Mode button. A floating chat button is in the lower corner.Select AI Mode and ask questions, such as Show polka dot pants or What should I wear to a wedding?. The agent returns matching products from the quickstart-products index.

Customize the assistant experience

Use emptyComponent to show a welcome message before the first chat message. Prompt suggestions help users start a conversation.Add the prompts and welcome component before the App component:
src/App.tsx
Pass ShoppingAssistantWelcome to the Chat component:
src/App.tsx
Add styles for the prompt suggestions to src/App.css:
src/App.css
For more information, see Customize the chat welcome screen.
Use translations to change the AI Mode button label and chat title.
src/App.tsx
You set cost controls and rate limits during agent creation in the Safety Controls stage. You can adjust them anytime to manage LLM usage. Cost controls limit output tokens, tool or reasoning loops, and conversation length. Rate limits restrict calls to the agent’s /completions endpoint.For more information, see Cost control and Rate limiting.

What’s next

Last modified on August 7, 2026