B2B Cross-Sell

Pick a product and get what is bought with it: _relate over past order baskets ranks the products that co-occur with it by lift, with the counts behind each pair.

📋 ERP_relateERP
In the demoIn the ERP demo's Retail profile, each anchor product lists the products bought with it, ranked by _relate lift over order baskets with the counts shown. Measured against simply counting co-occurrences, it lands at parity on well-bought products (55 vs 57 of 90) and behind on rarely bought ones (1 vs 18 of 90).

The problem

In B2B ordering the buyer usually knows the main item and forgets the rest: the consumables, the accessories, the part that always goes with it. Catalog cross-sell lists are curated by hand, and nobody curates the long tail.

How it works

_relate over the order baskets ranks the products that appear with the anchor more often than their base rate, by lift, and shows the counts behind each pair so a thin pair reads as thin; pairs seen together in fewer than three baskets are left out. On products with enough history it performs on par with counting co-occurrences, and on rarely bought products counting does better; its value is that the same query gives the lift, the counts and the conditioning (a customer segment, a season) without a separate pipeline.

The Recommendations view is part of the ERP demo's Retail profile; the link opens it directly.

{
  "from": "baskets",
  "relate": [
    "products"
  ],
  "where": {
    "products": {
      "$has": "SKU-2764"
    }
  },
  "select": [
    "related",
    "condition",
    "lift",
    "fs"
  ],
  "orderBy": "lift",
  "limit": 60
}

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive ERP.

See it live

This use case runs in the 📋 ERP demo today. Click through to the live application and inspect the queries that produce the result.

Open the live demo →

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

B2B cross-sell: a prompt for Claude Code
Add B2B cross-sell to this codebase using Aito, a predictive database. The feature: recommend products each business customer is likely to order next, from our order lines.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/b2b-cross-sell/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-erp-demo/blob/main/src/recommendation_service.py and https://github.com/AitoDotAI/aito-erp-demo/blob/main/src/aito_client.py
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Measure before wiring the UI: hold out recent rows and report how often the item actually chosen is in the top 3, against the order we show today.
7. In the UI, show the ranking as suggestions, with the reasons where the query gives them. Nothing is applied without the user.

Ask me before changing anything outside the new feature.