Sync Shopify products to a Notion database
Every product gets a page in the merchant's Notion database, updated as it changes and archived when it's deleted.
What you'll build
What it shows: A synced model's own actions driving an outside API, jobs that run one at a time per store, and retrying only what the outside API says to retry.
Before you start
- The CLI:
npm i -g @inferencebureau/apps, thenib-apps loginonce. - A Shopify Partner organization, and a development store to install on.
- A Notion integration token and a database with the properties the README lists.
Create the app from the recipe
One command creates the app on Inference Bureau and downloads its files into ./my-notion-sync. Shopify recipes need --platform shopify.
ib-apps create my-notion-sync --platform shopify --recipe notion-syncTour 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/shopifyProduct/actions/ | shopifyProduct's create, update and delete queue syncProduct in onSuccess, with concurrencyKey: notion:<shop>. |
api/actions/syncProduct.ts, api/lib/notion.ts | The product's page is found by its Shopify ID property each time, so a repeated job updates the page it made. Rate limits and Notion's errors throw and retry; a refused token is kept as lastError for the admin page instead. |
api/models/notionConnection/ | Keeps the integration token as an encryptedString, never sent back to the page. |
api/actions/syncAll.ts, checkNotion.ts | syncAll queues a sync for every synced product (backfill doesn't run actions), and checkNotion checks the token, the database and its properties. |
tests/notion-sync.test.ts | Syncs, retries and a refused token, with Notion stubbed. |
// api/models/shopifyProduct/actions/update.ts
export const onSuccess: ActionOnSuccess = async ({ record, api }) => {
// One sync per store at a time: under Notion's rate limit, and two quick edits can't both make the page.
await api.enqueue("syncProduct", { productGid: record.shopifyId }, { shop: record.shop, concurrencyKey: `notion:${record.shop}`, retries: 8 });
};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_productsshopifyProductConnect Shopify and install
- Create the Shopify app in your Partner organization
- Install on a development store
- Paste a Notion integration token and database in the admin, then Sync all
On the Notion side: at notion.so/profile/integrations, make an internal integration and copy its token. Make a database with Name (title), Shopify ID (text), Status (select), Vendor (text), Type (text), Tags (multi-select) and Updated (date), then add the integration under the database's … → Connections.
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-notion-sync
ib-apps devLogs show a succeeded config release once the extension is live.
Try it end to end
Make it yours
The page's properties are written in api/lib/notion.ts.
Tick it under Edit scopes and data models, then queue syncProduct's twin from its actions.
ib-apps test runs its tests, then ib-apps deploy sends development to production. See Deploys.