E-commerce · n8n

Get Instant Telegram Alerts When Shopify Products Run Low on Stock

This workflow checks your Shopify product inventory on a schedule and sends a Telegram message whenever any variant drops below your defined threshold. Stop losing sales to stockouts by catching low inventory before it becomes a problem.

difficulty Intermediatesetup 30 minresult You receive an automatic Telegram alert listing every Shopify product variant that has fallen below your chosen stock threshold, so you can reorder in time.
  1. 1

    Schedule the inventory check

    Add a Schedule Trigger node. Set Trigger Interval to Hours and Every to 6 (or any interval you prefer). This node fires the workflow automatically throughout the day so you never have to check manually.

  2. 2

    Fetch products from Shopify

    Add an HTTP Request node named Get Shopify Products. Set Method to GET and URL to https://YOUR-STORE.myshopify.com/admin/api/2024-01/products.json?limit=250&fields=title,variants. In the Authentication dropdown choose Header Auth and add header X-Shopify-Access-Token with your private app token. Store your shop URL and token in n8n credentials for safety.

  3. 3

    Extract variants and filter low stock

    Add a Code node named Filter Low Stock. Paste this JavaScript: const threshold = 10; const products = items[0].json.products; const alerts = []; for (const p of products) { for (const v of p.variants) { if (v.inventory_quantity <= threshold) { alerts.push({ product: p.title, variant: v.title, qty: v.inventory_quantity }); } } } return alerts.map(a => ({ json: a }));. Change threshold to your preferred minimum stock level.

  4. 4

    Stop if no low-stock items found

    Add an IF node named Any Low Stock?. Set Condition to Number, left value to {{ $input.all().length }}, operator larger than, right value 0. Connect the Filter Low Stock node output to this IF node. Only the true branch continues to send a Telegram message, preventing empty alerts.

  5. 5

    Send Telegram alert

    Add a Telegram node named Send Alert. Connect it to the true output of the IF node. Set Operation to Send Message, enter your Chat ID (your personal ID or a group ID), and set Text to Low Stock Alert! {{ $input.all().map(i => i.json.product + ' - ' + i.json.variant + ': ' + i.json.qty + ' left').join(' ') }}. Add your Telegram Bot API token in n8n Telegram credentials.

Frequently asked questions

How do I create a Shopify API token?

In your Shopify admin go to Settings > Apps and sales channels > Develop apps. Create a new app, then under Configuration grant it read access to Products and Inventory. Install the app and copy the Admin API access token shown on the API credentials tab.

How do I find my Telegram Chat ID?

Start a chat with the bot @userinfobot on Telegram and it will reply with your personal Chat ID. For a group, add your bot to the group, send a message, then visit https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates in a browser and look for the chat id field in the response.

Can I check inventory more than 250 products?

The Shopify API returns up to 250 products per page. If your store has more, add pagination by using the `page_info` cursor from the response Link header and looping with additional HTTP Request nodes. For most small to mid-size stores 250 products per call is sufficient.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.