Promote Shopify best-sellers in Algolia every Monday

Every Monday morning, we spot your top-selling Shopify products and pin them to the top of the Algolia search results shoppers actually type.

Agentic Task
AlgoliaShopifyMarketingOperationsData SyncContent Generation
PromptCreate

Every Monday at 7am, promote my Shopify best-sellers in Algolia search by creating query rules that boost them for the terms shoppers actually type.

Trigger: cron, Mondays at 7am.

Step 1. Call Shopify List Orders for the past 30 days (lookback window is a knob) and aggregate the line items to identify the top 20 best-selling products by unit volume. Hold on to each best-seller's product title, tags, and vendor, plus the Algolia objectID you use for it in your product index.

Step 2. Call Algolia Analytics: Top Searches over the same window to see the terms shoppers are actually typing, ranked by volume.

Step 3. For each best-seller, reason about which search terms it should show up for. Use the product title, tags, and vendor as hints, and match them against the top-searches list. Prefer terms with real search volume; skip vague, ambiguous, or off-brand matches so you do not over-pin.

Step 4. Before writing anything, use Algolia Get Rule on the objectID you would use (a stable slug per product/term pair, for example bestseller-pin-<productId>-<slug(term)>) to check whether an equivalent pin rule already exists and still applies to the same product. Skip those. Only queue rules that are genuinely new or need to replace a stale pin.

Step 5. Send the batch to Algolia Save Rules (batch) in one call to create or replace the queued query rules, each one pinning the best-seller's objectID in the top slot for the matched term.

Expose these knobs so the ruleset stays tidy: lookback window in days (default 30), top-N best-sellers cap (default 20), max rules per run (default 40), the Algolia index to write to, and an optional exclude list for products that should never be pinned (archived, out of stock, discontinued). Log a short summary at the end: how many best-sellers were considered, how many pins were already in place, and how many rules were written.

Additional information

What does this prompt do?
  • Looks at your last 30 days of Shopify orders and finds your top 20 best-selling products.
  • Pulls the search terms shoppers are actually typing on your site so it knows which queries are worth pinning to.
  • Matches each best-seller to the terms it should dominate, using product title, tags, and brand as hints.
  • Writes those match-ups as Algolia query rules, skipping any pin that is already in place and still valid.
What do I need to use this?
  • A Shopify store with recent order history.
  • An Algolia account with your product index and search analytics enabled.
  • A rough sense of how many pinned rules feels right for your storefront (there is a cap per run so nothing runs away).
How can I customize it?
  • Change how far back we look for best-sellers (default 30 days) and how many products we boost (default top 20).
  • Cap how many query rules get written per run so the ruleset stays tidy.
  • Point it at a specific Algolia index and exclude products you never want pinned (archived, sold out, gift cards).

Frequently asked questions

Will this overwrite Algolia query rules I already wrote by hand?
No. It only touches the pin rules it created itself, identified by a predictable objectID. Anything you set up manually for other queries stays exactly as you left it.
What happens when my best-sellers change?
Every Monday it recomputes best-sellers from the last 30 days of orders. As your top products shift, the pinned lineup shifts with them and stale pins get replaced on the next run.
Do I need Algolia's search analytics turned on?
Yes. That is where the real shopper-typed search terms come from. It is included on most Algolia plans; you just need to make sure analytics is enabled on the index you are pinning to.
What if a best-seller goes out of stock?
You can hand it a list of products to exclude, so out-of-stock or archived items never get pinned. That way shoppers do not land on an empty product page from a boosted search result.
Can I run it more often than weekly?
Yes. Weekly is a sensible default, but you can switch it to daily, monthly, or right after a big sale. The workflow itself does not care about the cadence.

Turn your best-sellers into your top search results.

Let your Shopify sales data drive Algolia relevance every week, without touching a rule by hand.