Schedule icon
Search icon
SlackIncomingWebhook icon

Daily Typesense Out-of-Stock Sweep Sorted by Popularity

Sweep Typesense for out-of-stock products with Kestra. Filter in_stock:false, sort by popularity, and send the hit count to Slack so ops fixes top sellers.

Categories
BusinessData

Most storefronts hide out-of-stock products from customers, which also hides them from the people who could fix availability. This blueprint keeps them visible to ops. A scheduled io.kestra.plugin.typesense.Search sweeps the products collection with filter: in_stock:false and sortBy: popularity:desc, so the stored result is not just a list of gaps but a priority list: the most popular unavailable products come first. Slack gets the count every morning.

How it works

  1. sweep_out_of_stock (io.kestra.plugin.typesense.Search) runs a match-all query (query: "*", queryBy: name) narrowed by filter: "in_stock:false" and ordered by sortBy: "popularity:desc".
  2. The task exposes {{ outputs.sweep_out_of_stock.totalHits }} as a scalar hit count and stores the full ordered result set in internal storage at {{ outputs.sweep_out_of_stock.uri }}.
  3. notify_ops posts the count to Slack and points at the execution's Outputs tab for the ordered list; only the scalar is interpolated into the JSON payload.
  4. The errors block posts a distinct Slack alert when the sweep fails, because a missing availability report is itself an availability blind spot.
  5. A disabled-by-default Schedule trigger runs the sweep daily at 07:00.

The connection uses the Typesense default port 8108 as a plain value and https: false for a local or private-network cluster; set https: true when your production cluster terminates TLS.

What you get

  • A daily, popularity-ordered list of unavailable products, computed from the same index the storefront searches.
  • The out-of-stock count as a scalar output, ready for thresholds or trend tracking.
  • A morning Slack nudge that turns availability from a dashboard nobody opens into a task list.
  • A failure alert so the sweep itself never silently stops running.

Who it's for

  • E-commerce ops teams deciding which stockouts to chase first.
  • Inventory managers who want popularity, not alphabetical order, driving the restock queue.
  • Search engineers demonstrating that the index can answer operational questions, not only customer queries.

Why orchestrate this with Kestra

The filter query takes milliseconds; the discipline of running it every morning, keeping each day's list, telling the right channel, and noticing when it breaks is the hard part. Kestra provides the schedule, the per-execution stored result for day-over-day comparison, the notification, and the failure alert in one flow you can read in a minute.

Prerequisites

  • A running Typesense cluster with a populated products collection whose schema includes in_stock (bool, faceted) and popularity (float); the nightly catalog index blueprint creates it.
  • A Slack incoming webhook for the report and failure alerts.

Secrets

  • TYPESENSE_HOST: hostname or IP of the Typesense node or load balancer.
  • TYPESENSE_API_KEY: an API key with search access to the collection.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL.

Quick start

  1. Add the three secrets to your Kestra namespace.
  2. Execute the flow and check the Slack message reports the out-of-stock count.
  3. Download the stored result from the execution's Outputs tab and confirm the most popular products lead the list.
  4. Set disabled: false on the daily trigger.

How to extend

  • Add an If task that escalates to an on-call channel when totalHits crosses a threshold.
  • Narrow the sweep to one category with filter: "in_stock:false && category:footwear".
  • Feed {{ outputs.sweep_out_of_stock.uri }} into a Python task that renders the top ten products into the Slack message.
  • Run the sweep after each nightly rebuild instead of on its own clock by chaining it to the catalog index flow.

Links

Orchestrate with Kestra
Orchestrate Slack with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.