Shopify Low Stock & Out-of-Stock Discord Alerts via Webhook

High-Level Summary

This workflow provides real-time inventory monitoring for your Shopify store. When a product's inventory level changes (e.g., after a sale or manual update), Shopify sends a webhook to n8n. The workflow then analyzes the new stock level: if it's low (between 1 and 3 units) or completely out of stock (0 units), it fetches detailed product information (title, variant, image, and exact quantity) from Shopify's GraphQL API and sends a beautifully formatted alert to a Discord channel. This helps store owners and operations teams react instantly to stockouts or low-stock situations, preventing lost sales and improving customer satisfaction.

Step-by-Step Node Breakdown

  1. Webhook — Receives the incoming HTTP POST request from Shopify when an inventory level is updated. (No auth – the webhook URL itself is the secret)

    • Parameters: Listens on path 5dc2467c-0b39-43e9-bdbd-399231f69c4e for POST requests. The webhook ID is auto-generated by n8n.
  2. Code — Processes the raw webhook payload to extract and classify the inventory status. (No auth)

    • Parameters: JavaScript code extracts available (current stock count) and inventory_item_id from the incoming JSON body. It then calculates two boolean flags: low_inventory (true if stock is 1–3) and out_of_stock (true if stock is 0). These flags are passed downstream to the conditional nodes.
  3. Low Inventory (IF node) — Routes the workflow based on whether the product has low stock. (No auth)

    • Parameters: Checks if $json.low_inventory equals true. If true, execution flows to the left output (the low-stock alert path).
  4. Out of Stock (IF node) — Routes the workflow based on whether the product is sold out. (No auth)

    • Parameters: Checks if $json.out_of_stock equals true. If true, execution flows to the left output (the out-of-stock alert path).
  5. GraphQL1 - shopify — Fetches detailed product data from Shopify for low-stock items. (Header Auth – uses a pre-configured credential with Shopify API token)

    • Parameters: Sends a GraphQL query to the endpoint defined in the environment variable API_BASE_URL (e.g., https://your-store.myshopify.com/admin/api/2023-01/graphql.json). The query retrieves the product title, variant title, inventory quantity, and the first product image URL using the inventoryItem ID passed from the Code node.
  6. GraphQL - shopify — Same as node 5, but for out-of-stock items. (Header Auth)

    • Parameters: Identical GraphQL query and endpoint, triggered when the product is out of stock.
  7. HTTP Request — Sends a low-stock alert to Discord. (Predefined Credential Type – uses a Discord webhook URL stored as a credential)

    • Parameters: POST method with a raw JSON body containing a Discord embed. The embed includes:
      • Title: Product name from Shopify
      • Description: "This product is running out of stock!"
      • Color: Yellow (hex 16776960)
      • Fields: Remaining inventory quantity and product variant name
      • Image: Product image from Shopify
      • Footer: "Alert from inventory management system"
  8. HTTP Request1 — Sends an out-of-stock alert to Discord. (Predefined Credential Type)

    • Parameters: Same structure as node 7, but with a red color (16711680) and description "This product is sold out!"

Setup Instructions

  1. Shopify Account: You need a Shopify store with admin access. Create a private app or use the Shopify Admin API to generate an access token with read_inventory and read_products scopes.
  2. Discord: Create a Discord server (or use an existing one). Go to Server Settings → Integrations → Webhooks → Create a webhook. Copy the webhook URL.
  3. n8n Credentials:
    • Create a Header Auth credential for Shopify: set the header name to X-Shopify-Access-Token and the value to your Shopify admin API token.
    • Create a Webhook URL credential for Discord: paste the Discord webhook URL as the credential value.
  4. Environment Variables: Set API_BASE_URL in your n8n environment to your Shopify GraphQL endpoint (e.g., https://your-store.myshopify.com/admin/api/2023-01/graphql.json).
  5. Shopify Webhook: In your Shopify admin, go to Settings → Notifications → Webhooks. Create a new webhook with:
    • Event: Inventory levels update
    • Format: JSON
    • URL: Your n8n webhook URL (the one generated by the Webhook node, e.g., https://your-n8n-instance.com/webhook/5dc2467c-0b39-43e9-bdbd-399231f69c4e)

Use Cases and Variations

  • Multi-channel Alerts: Replace the Discord HTTP Request nodes with Slack, Microsoft Teams, or email (using n8n's built-in nodes) to send alerts to your preferred platform.
  • Threshold Customization: In the Code node, adjust the lowInventory threshold (currently < 4) to any number (e.g., < 10 for high-volume items).
  • Inventory Reports: Instead of sending individual alerts, accumulate low-stock items over a time window (using the n8n Wait node) and send a daily summary.
  • Automated Reordering: Connect the out-of-stock branch to a purchase order system or a Google Sheets row to trigger automatic re-supply.
  • Slack Integration: Use the Slack node instead of HTTP Request for richer Slack message formatting with buttons to reorder directly.
  • Error Handling: The workflow already includes error-handler nodes (visible in the connections) – customize these to log errors to a separate channel or database.
15 nodeswebhook triggerDevOps
WebhookCodeIFHTTP RequestGraphqlSticky Note

Workflow JSON

{
  "meta": {
    "instanceId": "workflow-3abfd446",
    "versionId": "1.0.0",
    "createdAt": "2025-09-29T07:07:42.425841",
    "updatedAt": "2025-09-29T07:07:42.425854",
    "owner": "n8n-user",
    "license": "MIT",
    "category": "automation",
    "status": "active",
    "priority": "high",
    "environment": "production"
  },
  "nodes": [
    {
      "id": "174f80b5-6c84-47b3-a906-eeb4fc5207b8",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -840,
        620
      ],
      "webhookId": "5dc2467c-0b39-43e9-bdbd-399231f69c4e",
      "parameters": {
        "path": "5dc2467c-0b39-43e9-bdbd-399231f69c4e",
        "options": {},
        "httpMethod": "POST",
        "responseCode": null
      },
      "typeVersion": 1,
      "notes": "This webhook node performs automated tasks as part of the workflow."
    },
    {
      "id": "e03fc5ca-9446-44b7-9c0a-44c8696ec06a",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -540,
        620
      ],
      "parameters": {
        "jsCode": "\nconst available = items[0].json.body.available;\nconst inventory_item = items[0].json.body.inventory_item_id;\nconst lowInventory = available > 0 && available < 4;\nconst outOfStock = available === 0;\n\nreturn [\n  {\n    json: {\n      available: available,\n      inventory_tem: inventory_item,\n      low_inventory: lowInventory,\n      out_of_stock: outOfStock,\n    },\n  },\n];"
      },
      "typeVersion": 1,
      "notes": "This code node performs automated tasks as part of the workflow."
    },
    {
      "id": "2e8b6898-87aa-4e27-80df-647f022e7810",
      "name": "Low Inventory",
      "type": "n8n-nodes-base.if",
// ... truncated (copy to see full JSON)

How to Import This Workflow

  1. 1Copy the workflow JSON above using the Copy Workflow JSON button.
  2. 2Open your n8n instance and go to Workflows.
  3. 3Click Import from JSON and paste the copied workflow.

Don't have an n8n instance? Start your free trial at n8nautomation.cloud

Related Templates

Automated n8n Workflow Backup to GitHub Repository

Overview This workflow automatically backs up every workflow in your n8n instance to a dedicated GitHub repository. It runs on a configurable schedule (or manually) and ensures that all your workflow JSON files are version-controlled and safely stored in a structured folder. The backup process intelligently handles both new workflows (creates a file) and existing ones (updates the file), making it ideal for disaster recovery, collaboration, or tracking changes over time. Step-by-Step Node Breakdown Schedule Trigger (No additional auth) — Triggers the workflow on a recurring interval. By default it runs hourly, but you can customize the schedule (e.g., daily at midnight) to suit your needs. Also supports manual execution via the Manual Trigger node. Manual Trigger (No auth) — Provides a manual button to run the backup immediately, useful for testing or on-demand backups. Get many workflows (Internal n8n API, no external credentials) — Fetches a list of all workflows from your n8n instance using the built-in n8n node. No separate API key is required; it uses the same authentication as your n8n session. Loop Over Items (No auth) — Iterates over each workflow in the list one at a time. This node processes workflows sequentially, preventing race conditions. Getafile (GitHub, OAuth2 / Personal Access Token) — Attempts to retrieve the existing workflow file from your GitHub repository at the path . If the file does not exist (i.e., a new workflow), the node’s error output is triggered. The expression in sanitizes the workflow name by replacing invalid characters (), converting to , and normalizing spaces. Convert to File1 (No auth) — Converts the retrieved GitHub file’s binary data back to a JSON object so it can be compared or overwritten. Extract from File1 (No auth) — Extracts the JSON content from the binary file, preparing it for an update operation. Edit a file (GitHub, OAuth2 / Personal Access Token) — If the workflow already exists on GitHub, this node updates the file with the latest JSON from your n8n instance. The commit message is dynamically generated (e.g., ). Convert to File (No auth) — Converts the current n8n workflow JSON into a binary file () with the workflow’s name as the filename. Create a file (GitHub, OAuth2 / Personal Access Token) — If the workflow is new (i.e., error output), this node creates a new file in the folder. The commit message includes the workflow name and . The workflow loops back to the Loop Over Items node to process the next workflow. The Sticky Note at the top serves as a comment. Setup Instructions GitHub account — You need a GitHub account and a repository (e.g., ) to store the backups. Create an empty repository or use an existing one. GitHub credential in n8n — Add a GitHub OAuth2 or Personal Access Token credential in n8n under Credentials > GitHub. Ensure the token has scope (or at least and ). Configure the nodes — - In Get many workflows, no changes needed. - In Getafile, Create a file, and Edit a file, update the and fields to match your GitHub username and repo name. - Optionally adjust the Schedule Trigger interval (set hours/minutes as desired). Error handling — The workflow references an external error workflow (). If you don’t have that, you should either create a simple error handler or remove the setting in the workflow settings. Use Cases & Adaptations Disaster recovery — Restore all workflows by downloading the JSON files from GitHub and importing them back into n8n. Version history — Track changes to workflows over time via GitHub commits and diffs. Multi-instance sync — Modify the workflow to run on multiple n8n instances, pushing to the same repo (be cautious with conflicts). Selective backup — Add a filter node after to only backup workflows with a specific tag or name pattern. Notification — Insert a Slack or email node after the loop to notify you when a backup completes or if an error occurs.

11 nodes

Bitbucket Push Event Listener (Foundation Template)

Overview This workflow provides a minimal yet production-ready foundation for listening to Bitbucket repository push events. It triggers automatically whenever code is pushed to a specified repository, making it an ideal starting point for building CI/CD pipelines, deployment automation, notification systems, or any other custom workflow that reacts to code changes. An integrated error handler ensures the workflow fails gracefully and can be extended with additional error reporting. Workflow Nodes Bitbucket Trigger (OAuth2 auth) — Listens for events on a Bitbucket repository. Configured parameters: - : — Only triggers on push events (other event types like pull requests can be added). - : — Monitors changes at the repository level. - : — The Bitbucket repository slug to watch (should be updated to your actual repository name). This node acts as a webhook receiver. It requires authentication via n8n's built-in Bitbucket OAuth2 integration (or a personal access token) to register and manage the webhook automatically. Error Handler (No auth) — type . If any node during execution fails, this handler stops the workflow and logs the error message . It does not require external credentials and serves as a safety net to prevent silent failures. Note: As provided, the nodes are not connected (no data flows between them). The workflow is a structural template—you must add additional nodes (e.g., HTTP Request, Slack, Jira) after the trigger to actually process the event payload. Setup Instructions Bitbucket Account & Repository – Ensure you have a Bitbucket account and a repository (public or private) that you want to monitor. n8n Bitbucket Credentials – In n8n, go to Credentials > New > Bitbucket OAuth2. Follow the OAuth flow to authorize n8n to access your Bitbucket account. Alternatively, you can use a Bitbucket App Password with appropriate permissions (though OAuth2 is recommended). Configure the Trigger – Open the Bitbucket Trigger node and update the field to your actual repository slug (e.g., ). Leave other parameters as default unless you need different events. Deploy & Test – Activate the workflow. Push a commit to the repository; the trigger should fire. If no additional nodes are connected, the workflow will end immediately (which is expected). Use Cases & Adaptations Continuous Integration – Add an HTTP Request node to call a Jenkins or GitHub Actions API to trigger a build. Deployment Automation – Connect a Docker or SSH node to deploy the latest code to a staging or production server. Notifications – Use a Slack or email node to alert the team of new pushes with commit details. Issue Tracking – Post a comment to a Jira issue linked to the commit. Code Quality – Run a linter or test suite via a command node and report results. To adapt, simply append new nodes after the trigger and map fields from the Bitbucket event payload (e.g., for the branch name). You can also change the parameter to listen for pull request creation, branch deletion, or other Bitbucket webhook events.

2 nodes

Manual Trigger with Error Handler - Production Template

Overview This is a foundational n8n workflow template designed to demonstrate a robust, production-ready pattern for manual workflow execution with integrated error handling. It provides a clean starting point for building more complex automations by establishing best practices for error management and workflow structure from the outset. The workflow is intentionally minimal but includes critical production features: a manual trigger for on-demand execution, a dedicated error handler node that gracefully stops execution on failure, and comprehensive workflow settings configured for reliability (retry logic, timeout limits, and execution tracking). This makes it ideal for users who want to learn n8n's error handling capabilities or need a reliable skeleton for mission-critical automations. Workflow Steps Manual Trigger (No auth) — This is the starting point of the workflow. It allows you to run the workflow manually by clicking the "Execute Workflow" button in the n8n editor. No authentication is required for this trigger node itself. The node has no additional parameters configured, meaning it simply fires when manually activated. Error Handler (No auth) — Connected as an error workflow handler (though in this JSON it is not wired via connections, it is placed as a standalone error-catching node). This node uses the "Stop and Error" type, which means if any error occurs during workflow execution, this node will catch it and stop the workflow with a custom error message: "Workflow execution error". The parameter is empty, so no additional error handling behavior (like sending notifications) is configured. No authentication is required. Setup Instructions No external accounts required — This workflow uses only built-in n8n nodes (Manual Trigger and Stop & Error). You do not need any third-party service accounts or API keys. Import the workflow — Copy the JSON and paste it into your n8n instance via "Workflows > Add Workflow > Import from JSON". Customize the error message — If desired, edit the Error Handler node's "Message" parameter to provide a more specific error description relevant to your use case. Add your logic — Connect additional nodes after the Manual Trigger to perform your actual automation tasks. The Error Handler will automatically catch any errors from those nodes. Configure workflow settings — Review the existing settings (retry on fail, timeout, etc.) and adjust them to match your production requirements. Use Cases and Variations Learning template — Use this as a teaching tool to understand how error handling works in n8n workflows. Production skeleton — Start every new automation by duplicating this workflow, then add your business logic nodes between the trigger and error handler. Error notification system — Extend the Error Handler by adding a Slack, email, or webhook node after it to send alerts when errors occur. Multi-trigger adaptation — Replace the Manual Trigger with a Schedule Trigger, Webhook Trigger, or Event Trigger to make the workflow run automatically. Conditional error handling — Add an IF node before the Error Handler to route different error types to different handling logic (e.g., retry vs. notify vs. log).

2 nodes

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.