In this quickstart,
you’ll use Agent Studio with an LLM to build a conversational assistant that queries a products index, avoids hallucinations, and respects the index’s settings and ranking.
1
Create a product catalog index
Go to the Algolia dashboard and create a new index. Use products as the index name.
Download the records.json file.The records.json file contains product listing records with attributes such as name, categories, price, and brand. For example:
JSON
{ "name": "ROCCAT - Taito Control Mouse Pad - Black/Blue", "description": "Beat your opponent with a click of your mouse on this ROCCAT Taito Control ROC-13-170-AM mouse pad that is compatible with a wide range of optical and laser gaming mice. The total-control surface ensures smooth, precise mouse movement.", "brand": "ROCCAT", "categories": [ "Computers & Tablets", "Mice & Keyboards", "Mouse & Wrist Pads" ], "hierarchicalCategories": { "lvl0": "Computers & Tablets", "lvl1": "Computers & Tablets > Mice & Keyboards", "lvl2": "Computers & Tablets > Mice & Keyboards > Mouse & Wrist Pads" }, "type": "Gaming controllers", "price": 14.99, "price_range": "1 - 50", "image": "https://cdn-demo.algolia.com/bestbuy/4384501_sb.jpg", "url": "http://www.bestbuy.com/site/roccat-taito-control-mouse-pad-black-blue/4384501.p?id=1219740718517&skuId=4384501&cmp=RMX&ky=1uWSHMdQqBeVJB9cXgEke60s5EjfS6M1W", "free_shipping": false, "popularity": 1548, "rating": 2, "objectID": "4384501"}
The conversational assistant app will search and reference these when answering product-related questions.
Click Upload records > Upload file, and select the records.json file you downloaded.
2
Add LLM provider credentials
From Agent Studio’s Settings page, click Create provider profile.
Select your preferred provider and enter the appropriate credentials:
Azure OpenAI: paste in your chosen key value (as API Key) and endpoint URL. Then choose an LLM model and API version.
Gemini: paste in your Google AI Studio API key.
OpenAI: paste in your API key and select a region.
On the left sidebar, select Generative AI > Agent Studio > Agents, then click Create your first agent or Create agent.
Click Start from scratch.
Paste the following into the Instructions box:
You are a shopping assistant.Your goal is to help users find products in the product catalog using Algolia search.Scope:- Only answer questions about products in the catalog.- If asked about anything else, reply: "I can only answer questions about the product catalog."- If an item is not found in the catalog, reply: "Sorry. I couldn't find any matching items." and stop.Behavior:- Use a clear and friendly tone.- When helpful, include product names, short descriptions, prices, categories, and links.- Return at most five results per query.- Ask up to two clarifying questions if the query is ambiguous (confidence is less than 95%).- On timeout or error, reply once: "An error occurred. Try rephrasing your request."Restrictions:- Stop searching after five search attempts per session. If no products are found after that, send the "no matching items" message and stop.Language:- Reply in English.Output formatting:- Use bold labels followed by values, one per line. For example: **Name**: ROCCAT Mouse Pad **Price**: $14.99 **Brand**: ROCCAT **Link**: <https://example.com/product>- Always insert two spaces at the end of each line to ensure proper line breaks in markdown.- Don't use bullet points or numbered lists.- Always format links using angle brackets to show the raw URL.
Click Add tools, choose Algolia Search, and select the products index.To see supported tool types beyond the Search tool, see Tools for Agent Studio.
For Description, enter Product catalog, click Save, then Add tool.
Click Change provider and choose the LLM provider you added in step 2.
4
Test and publish the agent
Use the preview panel on the right to test your new agent with a sample query.For example, if you say “What Christian Siriano cases do you have?”,
you should expect it to list a handful of products.
You can also ask follow-up questions, for example, to filter by price or category.
After asking a few questions, click Publish.
Close the confirmation box.
5
Build a conversational assistant app
To create a new React app with Vite, enter the following commands in your terminal (on Windows, use PowerShell, not Command Prompt):
Add the following credentials after the appropriate = character:
VITE_ALGOLIA_APPLICATION_ID is your Algolia Application ID, found under API Keys in the dashboard.
VITE_ALGOLIA_API_KEY is your Search API key from the same page.
AGENT_ID is your agent ID. Find it on the Agents overview page, click View actions > Copy ID.
6
Run the conversational assistant app
Run the app.
Command line
npm run dev
Open the local URL http://localhost:5173 in your browser and test the conversational assistant app.
For example, ask “What’s the best compact refrigerator?”
If your app fails to connect, check that:
Your agent is published.
The variables in the .env.local file are correct.
You’re using the Algolia Search API key, not something else.