Product quiz
Apps/Recipes/Product quiz

Build a product quiz for a Shopify store

The merchant writes questions in the admin and points each answer at products; shoppers take the quiz from a theme block and land on their matches, rendered in the theme. It needs no Shopify scopes: the block renders from an app-data metafield, and the app proxy does the rest.

Shopify, customScopes noneRecipe id quiz

What you'll build

Quiz editorquestions → productsquiz.publishapp-data metafieldProduct quiz blocka Liquid formquizResponse.createtop 3 productsResults pagerendered in Liquid

What it shows: Publishing app data to an app-data metafield, a theme block that is a plain Liquid form with no script, and results answered as Liquid through the app proxy.

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-quiz. Shopify recipes need --platform shopify.

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

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/quiz/, api/lib/quiz.tsThe quiz model (one per store) with questions as JSON, checked on save; ids are kept across edits and never reused.
actions/publish.ts, unpublish.ts, update.tsPublish writes the questions, without their products, to app.metafields.quiz.definition; Unpublish deletes it; an edit republishes a live quiz, and so does a reinstall.
extensions/quiz/The Product quiz block: a form rendered in Liquid, posting to the app proxy.
web/app/proxy/quiz/, api/models/quizResponse/quizResponse.create scores the answers against the live quiz (top 3 products), then redirects to a results page answered as Liquid with all_products.
api/actions/shopifyCustomers*.tsShopify's privacy webhooks: customers/redact deletes the customer's responses, for a customer who took the quiz signed in; customers/data_request emails them to the store's owner through the team's own Resend account.
tests/quiz.test.tsThe actions, scoring and publishing, with the Admin API mocked.
{%- liquid
  assign quiz = app.metafields.quiz.definition.value
  assign proxy = app.metafields.ib_app.proxy_path.value
-%}
{%- if quiz.questions.size > 0 and proxy != blank -%}
<form class="ibq" method="post" action="{{ proxy | escape }}/quiz">
  <input type="hidden" name="return_to" value="{{ request.path | escape }}">
  {%- for q in quiz.questions -%}
    <fieldset><legend>{{ q.text | escape }}</legend>
      {%- for a in q.answers -%}
        <label><input type="radio" name="q_{{ q.id | escape }}" value="{{ a.id | escape }}" required> {{ a.text | escape }}</label>
      {%- endfor -%}
    </fieldset>
  {%- endfor -%}
  <button type="submit" class="button">{{ block.settings.submit_label | escape }}</button>
</form>
{%- endif -%}

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
Scopesnone
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
  3. Write the questions in the admin and publish; add the Product quiz block in the theme editor

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-quiz
ib-apps dev

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

Try it end to end

0 of 5 checked

Make it yours

Restyle the form

extensions/quiz/assets/quiz.css and blocks/product-quiz.liquid.

Change the scoring

It's in api/models/quizResponse/; run ib-apps test after.

Ship it

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