The Gap in Every AI Shopping Chatbot
Every major tech company is shipping AI shopping assistants. They can understand natural language, reason about tradeoffs, and recommend products. But ask one "what does this jacket cost in size XL?" and you'll usually get a hallucinated, stale, or variation-incorrect answer.
The gap isn't in the LLM. It's in the data layer that feeds the LLM.
This guide shows you how to fill that gap by integrating Pricium - a real-time, variation-aware product data API - into your AI chatbot.
Architecture Overview
User message → LLM (intent detection) → Pricium API (product data) → LLM (response generation) → User
The LLM handles two things:
- Detecting that the user is asking about a product and extracting the URL and preferences
- Formatting the structured product data from Pricium into a natural language response
Pricium handles the hard part: fetching accurate, variation-specific, real-time pricing.
Step 1: Set Up Your Project
mkdir ai-shopping-bot && cd ai-shopping-bot
npm init -y
npm install openai axios dotenv
Create .env:
OPENAI_API_KEY=sk-...
PRICIUM_API_KEY=pk-...
Step 2: Product Data Fetcher
Create productFetcher.js:
const axios = require('axios');
async function fetchProductData(url, location = 'US') {
const response = await axios.post(
'https://api.pricium.store/scrape',
{ url, location },
{
headers: {
Authorization: `Bearer ${process.env.PRICIUM_API_KEY}`,
'Content-Type': 'application/json',
},
}
);
return response.data;
}
module.exports = { fetchProductData };
Step 3: The Chatbot with Tool Calling
Create chatbot.js:
require('dotenv').config();
const OpenAI = require('openai');
const { fetchProductData } = require('./productFetcher');
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const tools = [
{
type: 'function',
function: {
name: 'get_product_data',
description: 'Fetches real-time pricing and availability for all variations of a product given its URL.',
parameters: {
type: 'object',
properties: {
url: { type: 'string', description: 'The product page URL' },
location: { type: 'string', description: 'Two-letter country code for geo-pricing (e.g. US, UK, IN)', default: 'US' },
},
required: ['url'],
},
},
},
];
async function chat(userMessage) {
const messages = [
{
role: 'system',
content: `You are a helpful shopping assistant. When a user asks about product pricing or availability, use the get_product_data tool to fetch real-time data. Always mention the specific variation prices and availability.`,
},
{ role: 'user', content: userMessage },
];
// First LLM call - may trigger tool use
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages,
tools,
tool_choice: 'auto',
});
const assistantMessage = response.choices[0].message;
if (assistantMessage.tool_calls) {
const toolCall = assistantMessage.tool_calls[0];
const args = JSON.parse(toolCall.function.arguments);
console.log(`🔍 Fetching product data for: ${args.url}`);
const productData = await fetchProductData(args.url, args.location);
// Second LLM call - generate response with tool data
messages.push(assistantMessage);
messages.push({
role: 'tool',
tool_call_id: toolCall.id,
content: JSON.stringify(productData),
});
const finalResponse = await client.chat.completions.create({
model: 'gpt-4o',
messages,
});
return finalResponse.choices[0].message.content;
}
return assistantMessage.content;
}
// Test it
chat('How much does https://amazon.com/dp/B0EXAMPLE cost in different sizes? I\'m in the UK.')
.then(console.log)
.catch(console.error);
Sample Output
Based on real-time pricing data:
**Levi's 501 Jeans** - prices for UK customers:
| Size | Color | Price | In Stock |
|-------|-----------------|---------|----------|
| 30x30 | Dark Stonewash | £39.99 | ✅ Yes |
| 32x30 | Dark Stonewash | £39.99 | ✅ Yes |
| 34x32 | Dark Stonewash | £43.99 | ❌ No |
| 30x30 | Light Stonewash | £36.99 | ✅ Yes |
The best available option in your region is the 30x30 Light Stonewash at £36.99.
This is the difference between an AI that guesses and an AI that knows.
What to Build Next
- Add conversation memory with LangChain or a vector DB for multi-turn shopping sessions
- Support multiple product URLs in one query for cross-product comparison
- Add price-drop notifications via webhook when Pricium detects a change
Build an AI shopping assistant users can actually trust. Get your Pricium API key →
