Tag Shopify products automatically
The merchant writes rules on the admin page ("products that mention merino get the tag Wool"); every product created or changed gets its rules' tags, and Tag every product applies them to the whole catalog.
What you'll build
What it shows: Webhook triggers, a long job split into pages, and work that's safe to repeat under Shopify's rate limits.
Before you start
- The CLI:
npm i -g @inferencebureau/apps, thenib-apps loginonce. - A Shopify Partner organization, and a development store to install on.
Create the app from the recipe
One command creates the app on Inference Bureau and downloads its files into ./my-tagger. Shopify recipes need --platform shopify.
ib-apps create my-tagger --platform shopify --recipe taggerTour 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.
| Where | What's there |
|---|---|
api/models/tagRule/ | The tagRule model: keyword, tag, on or off, and a unique key per store. |
settings.ib.ts, api/actions/tagProduct.ts | products/create and products/update queue tagProduct with only the fields it reads (includeFields). |
api/lib/tagger.ts | A rule matches whole words in the title, description, vendor or type. Only missing tags are added, with one tagsAdd; when none are missing nothing is called, which stops the products/update the tagging itself causes. |
api/actions/retagAll.ts | Tags 50 products per job and queues the next page with its cursor, under one concurrencyKey per store. A page still throttled after retries throws and is tried again. |
web/app/rules.tsx, web/app/api/ | The rules page; every route checks the session token and uses session.api. |
tests/tagger.test.ts | Rule matching, missing tags only, and the paged retag, with the Admin API mocked. |
export const settings: AppSettings = {
type: "ib/settings/v1",
platform: "shopify",
webhooks: [
{ topic: "products/create", action: "tagProduct", includeFields: ["admin_graphql_api_id", "title", "body_html", "vendor", "product_type", "tags"] },
{ topic: "products/update", action: "tagProduct", includeFields: ["admin_graphql_api_id", "title", "body_html", "vendor", "product_type", "tags"] },
],
};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.
read_products, write_productsproducts/create, products/update → tagProductConnect Shopify and install
- Create the Shopify app in your Partner organization
- Install on a development store
- Write a rule in the admin and change a product: Logs show
tagProduct
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-tagger
ib-apps devLogs show a succeeded config release once the extension is live.