Back

Nov 25, 2025

Product Recommendations

H
Hyperfold Team
AgentsSearch

Recommendation Types

Hyperfold supports multiple recommendation strategies:

  • Similar Products: Items with similar attributes/embeddings
  • Complementary Products: Items frequently bought together
  • Personalized: Based on customer purchase history
  • Trending: Popular items in the category

Similar Products

Find similar products using vector embeddings:

bash
1
2
3
4
5
6
7
8
9
10
# Test similar product recommendations
$ hyperfold catalog recommend similar prod_aero_x2 --limit=5
SIMILAR TO: AeroRun X2 Marathon Shoe
PRODUCT SIMILARITY PRICE CATEGORY
StormRunner Pro 0.94 $165 Running/Trail
SpeedLite X 0.91 $145 Running/Road
AeroRun X1 (Previous) 0.89 $150 Running/Marathon
CloudStep Elite 0.87 $185 Running/Premium

Complementary Items

Suggest items that go well together:

typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Vector-based similarity search
async function findSimilarProducts(productId: string, limit: number) {
const product = await getProduct(productId);
// Get product embedding
const embedding = product.embedding;
// Vector similarity search excluding the source product
const similar = await db.collection('products')
.where('product_id', '!=', productId)
.findNearest({
vectorField: 'embedding',
queryVector: embedding,
limit,
distanceMeasure: 'COSINE',
});
return similar.docs.map(doc => ({
...doc.data(),
similarity_score: doc.distance,
}));
}
// Complementary products based on purchase history
async function findComplementaryProducts(productId: string) {
// Query orders containing this product
const orders = await db.collection('orders')
.where('items', 'array-contains', productId)
.limit(100)
.get();
// Count co-purchased products
const coPurchased = new Map<string, number>();
for (const order of orders.docs) {
for (const item of order.data().items) {
if (item !== productId) {
coPurchased.set(item, (coPurchased.get(item) || 0) + 1);
}
}
}
// Return top co-purchased products
return [...coPurchased.entries()]
.sort((a, b) => b[1] - a[1])
.slice(0, 5)
.map(([id, count]) => ({ product_id: id, co_purchase_count: count }));
}

Personalization

Personalize recommendations based on customer context:

typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Personalized recommendations
async function getPersonalizedRecommendations(customerId: string) {
const customer = await getCustomerContext(customerId);
// Get customer's purchase history embedding
const historyEmbedding = await computeHistoryEmbedding(
customer.purchase_history
);
// Find products similar to their preferences
return await db.collection('products')
.findNearest({
vectorField: 'embedding',
queryVector: historyEmbedding,
limit: 10,
});
}

Bundle Suggestions

Use recommendations to create bundle offers:

typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Recommendation implementation
import { recommendSimilar, recommendComplementary } from '@hyperfold/tools';
@OnACPEvent('quote')
async handleQuote(productId: string, offer: number, context: any) {
const product = await getProduct(productId);
const pricing = await calculateDynamicPrice(product, context);
// Get recommendations for upsell/cross-sell
const [similar, complementary] = await Promise.all([
recommendSimilar(productId, { limit: 3 }),
recommendComplementary(productId, { limit: 2 }),
]);
return {
status: 'counter_offer',
price: pricing.suggested,
// Suggest premium alternative (upsell)
upsell_suggestion: similar.find(p => p.price > product.price),
// Suggest bundle (cross-sell)
bundle_suggestion: {
items: [product, ...complementary],
bundle_price: calculateBundlePrice([product, ...complementary]),
savings: calculateSavings([product, ...complementary]),
},
};
}
Bundles increase average order value by 20-30% on average. Always suggest relevant bundles during negotiation.