🀝 Send predictive Shopify low-stock alerts with Google Sheets, Slack, and Gmail

⚑ 33 views · 🀝 CRM & Sales Operations

Description

Quick overview

This workflow runs daily to calculate Shopify product sales velocity, predict days until stockout, and alert on low inventory. It logs alerted variant IDs to Google Sheets to avoid duplicate notifications, then sends a Slack summary and a detailed HTML email via Gmail, with Slack error alerts.

How it works

  1. Runs every day at 7:00 AM UTC on a schedule.
  2. Loads configuration values and reads the existing alert log from Google Sheets for deduplication.
  3. Fetches recent paid Shopify orders from the configured lookback window and retrieves all active Shopify products and variants with inventory tracking.
  4. Calculates per-variant daily sales velocity, estimates days of stock remaining, categorizes urgency, and skips variants already alerted for the current UTC date.
  5. Appends the newly alerted variant IDs and run metadata to Google Sheets as an alert log.
  6. Posts a Slack message with the urgency breakdown and predicted depletion timelines.
  7. Generates an HTML table report and sends it to the configured recipient using Gmail.
  8. If the workflow fails at any point, sends the failed node name and error message to Slack via the global error trigger.

Setup

  1. Connect Shopify OAuth2 credentials in n8n and ensure your store has access to Orders and Products APIs.
  2. Create a Google Sheet with headers runTimestamp, variantIds, and totalVariantsAlerted, connect Google Sheets OAuth2 credentials, and paste the sheet URL into the configuration.
  3. Connect Slack API credentials, set the Slack channel ID in the configuration (and select a channel for the error-alert Slack node), and connect Gmail OAuth2 credentials for sending email.
  4. Update daysToCalculateVelocity, recipientMail, googleSheetUrl, and slackEscalationChannel in the configuration, then adjust the schedule time if needed.

Requirements

Customization

πŸ”— Nodes Used

Google Sheets, Slack, Shopify, Gmail, Schedule Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup