Skip to main content

Scenario

Products sitting in warehouses need a sales push. You pull inventory levels from Shopify’s GraphQL API, identify high-stock / low-velocity items, and generate marketing copy for those products with urgency-appropriate messaging.

Architecture

Code

Example Output

Error Handling

inventoryLevels requires read_inventory scope. Update in Shopify Admin → Settings → Apps → your app → API scopes. Changes take effect immediately.
The code estimates velocity from current stock divided by an assumed time window. For accurate velocity, query order line items per product over 90 days and divide by weeks.