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.
- 1
Schedule the inventory check
Add a
Schedule Triggernode. SetTrigger IntervaltoHoursandEveryto6(or any interval you prefer). This node fires the workflow automatically throughout the day so you never have to check manually. - 2
Fetch products from Shopify
Add an
HTTP Requestnode namedGet Shopify Products. SetMethodtoGETandURLtohttps://YOUR-STORE.myshopify.com/admin/api/2024-01/products.json?limit=250&fields=title,variants. In theAuthenticationdropdown chooseHeader Authand add headerX-Shopify-Access-Tokenwith your private app token. Store your shop URL and token in n8n credentials for safety. - 3
Extract variants and filter low stock
Add a
Codenode namedFilter 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 }));. Changethresholdto your preferred minimum stock level. - 4
Stop if no low-stock items found
Add an
IFnode namedAny Low Stock?. SetConditiontoNumber, left value to{{ $input.all().length }}, operatorlarger than, right value0. Connect theFilter Low Stocknode output to this IF node. Only thetruebranch continues to send a Telegram message, preventing empty alerts. - 5
Send Telegram alert
Add a
Telegramnode namedSend Alert. Connect it to thetrueoutput of the IF node. SetOperationtoSend Message, enter yourChat ID(your personal ID or a group ID), and setTexttoLow 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.