Free Plan: Reply Cap and Monthly Reset
This document describes how the free plan reply limit is stored, enforced, and reset.
Database fields (shops table)
Section titled “Database fields (shops table)”| Column | Type | Description |
|---|---|---|
free_credit_limit | integer | Maximum number of AI replies allowed per month for this shop. Set when the store is created from .env FREE_PLAN_REPLIES_CAP (default 50). |
free_credits_used | integer | Number of AI replies used this month. Incremented by 1 each time the shop (on free plan) receives an AI reply. Reset manually when you want to start a new period (e.g. run resetFreeCreditsUsedForAllShops or UPDATE shops SET free_credits_used = 0). |
When values are set or updated
Section titled “When values are set or updated”-
Store creation
When a new shop is created (OAuth install),free_credit_limitis set fromprocess.env.FREE_PLAN_REPLIES_CAP(default 50).free_credits_usedis set to 0.
Seeapp/shopify.server.js(shop create). -
Each AI reply (free plan only)
After an AI reply is sent (either the canned “not enough information” message or a full LLM reply), the app incrementsfree_credits_usedby 1 for that shop.
Seeapp/lib/limits.server.js(incrementFreeCreditsUsed) andapp/lib/rag.server.js(called after sending a reply whenshop.plan === "free"). -
Monthly reset (manual)
The app does not resetfree_credits_usedautomatically. To reset usage for all shops (e.g. on the 1st of each month), run manually: callresetFreeCreditsUsedForAllShops(prisma)fromapp/lib/limits.server.js(e.g. from a script or admin-only route), or runUPDATE shops SET free_credits_used = 0in SQL.
Enforcing the limit (upgrade required)
Section titled “Enforcing the limit (upgrade required)”- Before generating an AI reply, the app checks the free plan limit in
checkReplyLimit(inapp/lib/limits.server.js). - If
free_credits_used >= free_credit_limit, the app throws REPLY_LIMIT_EXCEEDED and does not generate a reply. The API returns a 429 with a message that the monthly reply limit is exceeded and the merchant should upgrade to the paid plan. - The Billing page shows “X of Y replies used” for free plan using
free_credits_usedandfree_credit_limitso merchants can see usage and upgrade when needed.
Environment variable
Section titled “Environment variable”- FREE_PLAN_REPLIES_CAP
Used only when a new shop is created. Its value is stored inshops.free_credit_limitfor that shop. Default if unset: 50.
Existing shops keep their currentfree_credit_limit; change this env only affects new installs.
Migration
Section titled “Migration”- Migration
20260310000000_add_free_credit_limit_and_usedaddsfree_credit_limit(default 50) andfree_credits_used(default 0) toshops.
Existing shops get these defaults; new shops getfree_credit_limitfrom env at create time.