Product reviews
Apps/Recipes/Product reviews

Build product reviews for a Shopify store

Shoppers write reviews from a block on the product page, the brand approves or rejects each one in the Shopify admin, and approved reviews appear on the product page, rendered by Shopify with the page: no script loads them.

Shopify, customScopes write_productsRecipe id reviews

What you'll build

Product pageProduct reviews blockApp proxy/proxy/reviewsreview.createalways pendingModeration queueapprove · rejectMetafields$app:reviews

What it shows: A theme block that posts through the app proxy, moderation in an embedded admin page, and data published to product metafields so the storefront reads it from Liquid.

Before you start

  • The CLI: npm i -g @inferencebureau/apps, then ib-apps login once.
  • A Shopify Partner organization, and a development store to install on.
  • Resend, for data requests.

Create the app from the recipe

One command creates the app on Inference Bureau and downloads its files into ./my-reviews. Shopify recipes need --platform shopify.

ib-apps create my-reviews --platform shopify --recipe reviews

Tour what the recipe loaded

The recipe lies over the Shopify starter: files of the same path are replaced, and the starter's storefront block is dropped. Here's where each piece lives.

WhereWhat's there
api/models/review/schema.ib.tsThe review model: rating, title, body, author, the product's gid, the store, and a status (pending, approved, rejected) with who moderated it, when, and a note. It belongs to shopifyProduct when the app syncs products.
actions/create.tsA shopper's review is always created pending, whatever was sent.
actions/approve.ts, reject.ts, delete.tsApprove and Reject set the status and moderation fields, then republish the product's approved reviews in onSuccess. Delete takes an approved review down too.
api/lib/reviews.tsApproved reviews live in product metafields in the app-reserved namespace $app:reviews: list (the newest 50, JSON, kept under 64 KB) and summary ({ average, count }).
shopifyShop/actions/install.ts, reinstall.tsCreate the two metafield definitions, with storefront read access.
extensions/reviews/The Product reviews block reads product.metafields["$app:reviews"] and shows the stars, the count and the reviews. Its form posts to the app proxy.
web/app/proxy/reviews/route.tsChecks the request came through the storefront, validates the review and runs create.
web/app/page.tsx, moderation.tsx, api/reviews/The moderation queue. Its routes check the session token before reading or changing anything, and show only the signed-in store's reviews.
api/actions/shopifyCustomers*.tsShopify's privacy webhooks: customers/redact deletes the customer's reviews (by customer id, or a guest's email) and republishes the products that showed one; customers/data_request emails them to the store's owner through the team's own Resend account.
tests/reviews.test.tsThe actions against in-memory records, with the Admin API mocked: new reviews start pending, publishing and taking down, a refused publish, customers/redact, the install's definitions.
export async function POST(request: Request) {
  const proxy = await verifyProxyRequest(request);
  if (!proxy) return Response.json({ error: "Not found" }, { status: 404 });
  // …validate the form: 1–5 stars, lengths, a honeypot field…
  const api = createClient();
  // One review per shopper per product: a signed-in customer by id, a guest by email.
  const existing = await api.review.findFirst({ filter: { shop: { equals: proxy.shop }, productGid: { equals: productGid }, status: { in: ["pending", "approved"] }, ...who } });
  if (existing) return Response.json({ error: "You've already reviewed this product. Thanks!" }, { status: 409 });
  try {
    await api.review.run("create", { shop: proxy.shop, params: { productGid, shop: proxy.shop, rating, title, body, authorName, authorEmail, customerId: proxy.customerId } });
  } catch (e) {
    // The model's validations have the last word; their problems go back beside the fields.
    if (e instanceof ApiError && e.status < 500) return Response.json({ error: e.message, problems: Object.fromEntries(e.problems.map((p) => [p.field, p.message])) }, { status: 400 });
    throw e;
  }
  return Response.json({ ok: true, status: "pending" }, { status: 201 });
}

Check what it set on the app

Nothing to do here: this is what the recipe configured, so you know where to look in Settings later.

PlatformShopify, custom
Scopeswrite_products
Admin pagesInference Bureau
Webhookscustomers/redact, customers/data_request

Connect Shopify and install

  1. Create the Shopify app in your Partner organization
  2. Install on a development store: the install writes the metafield definitions
  3. Add the Product reviews block to the product template in the theme editor

Already installed on a store? Use Update scopes on Installs so it asks for write_products. Optionally tick the shopifyProduct model under Settings → Shopify → Edit scopes and data models, so reviews link to synced products and the queue shows product titles.

Run it

ib-apps dev syncs both ways while you work and runs the development server. Saving anything under extensions/ releases it to the development Shopify app by itself.

cd my-reviews
ib-apps dev

Logs show a succeeded config release once the extension is live.

Try it end to end

0 of 4 checked

Make it yours

Restyle the block

extensions/reviews/assets/reviews.css and the Liquid in blocks/product-reviews.liquid.

Change the rules

Validation is in actions/create.ts and the proxy route; run ib-apps test after.

Ship it

ib-apps test runs its tests, then ib-apps deploy sends development to production. See Deploys.