8
n8n 中文网amn8n.com

SHOPIFY库存低库存监控

中级

这是一个Miscellaneous领域的自动化工作流,包含 10 个节点。主要使用 If, Set, Code, Slack, Shopify 等节点。 监控Shopify库存并向Slack发送低库存警报

前置要求
  • Slack Bot Token 或 Webhook URL
  • Shopify Admin API 凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "zn8PCtQ6ISmR8ptG",
  "meta": {
    "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc"
  },
  "name": "SHOPIFY 库存低库存监控",
  "tags": [],
  "nodes": [
    {
      "id": "a02768c5-a7d4-491a-b140-befbcd5f2c7b",
      "name": "每日库存检查",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -840,
        340
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5b063339-70a3-4d41-a396-b3f49626ad78",
      "name": "获取所有产品",
      "type": "n8n-nodes-base.shopify",
      "position": [
        -620,
        340
      ],
      "parameters": {
        "resource": "product",
        "operation": "getAll",
        "returnAll": true,
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c992fedb-0c21-493f-8b0b-cbd6a7335a40",
      "name": "筛选低库存商品",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        340
      ],
      "parameters": {
        "jsCode": "const lowStockThreshold = 10; // Set your threshold\nconst lowStockProducts = [];\n\nfor (const product of $input.all()) {\n  for (const variant of product.json.variants) {\n    if (variant.inventory_quantity <= lowStockThreshold && variant.inventory_quantity > 0) {\n      lowStockProducts.push({\n        product_title: product.json.title,\n        variant_title: variant.title,\n        sku: variant.sku,\n        current_stock: variant.inventory_quantity,\n        product_id: product.json.id,\n        variant_id: variant.id\n      });\n    }\n  }\n}\n\nreturn lowStockProducts.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "ba2f6f7f-540a-4d48-99a5-75cb28c88753",
      "name": "检查是否需要警报",
      "type": "n8n-nodes-base.if",
      "position": [
        -180,
        340
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-001",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Filter Low Stock Items').all().length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f20e4aa3-588b-4da8-b0d4-e097711f1747",
      "name": "格式化警报消息",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        340
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"alert_message\": \"🚨 *Low Stock Alert*\\n\\nThe following items are running low:\\n\\n{{ $('Filter Low Stock Items').all().map(item => `• ${item.json.product_title} (${item.json.variant_title}): ${item.json.current_stock} left`).join('\\n') }}\",\n  \"products_count\": \"{{ $('Filter Low Stock Items').all().length }}\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "3ddc4707-1295-41cd-a874-f0601f66c995",
      "name": "发送库存警报",
      "type": "n8n-nodes-base.slack",
      "position": [
        260,
        340
      ],
      "webhookId": "4d8500c1-7086-4fc8-8b8b-6ff061c4381b",
      "parameters": {
        "text": "={{ $json.alert_message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C1234567890",
          "cachedResultName": "inventory"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "9b6e400f-d16d-44b3-8ee2-d68ac6a89fc3",
      "name": "工作流信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        160
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "## 📦 库存低库存监控"
      },
      "typeVersion": 1
    },
    {
      "id": "2b68b93f-b4a8-49d6-bb8d-87f4028cf81c",
      "name": "功能与配置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 6,
        "width": 300,
        "height": 280,
        "content": "**主要功能**:"
      },
      "typeVersion": 1
    },
    {
      "id": "9c1250d3-08bf-47da-bdf2-40b95bcb584d",
      "name": "商业价值",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        500
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 200,
        "content": "**商业价值**:"
      },
      "typeVersion": 1
    },
    {
      "id": "9fbe2564-05df-4453-9961-fe98d0873eb4",
      "name": "阈值指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        80
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 240,
        "content": "**阈值自定义**:"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "50ae8a36-065f-4c4f-a27d-f1970faaae12",
  "connections": {
    "Get All Products": {
      "main": [
        [
          {
            "node": "Filter Low Stock Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert Message": {
      "main": [
        [
          {
            "node": "Send Inventory Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Inventory Check": {
      "main": [
        [
          {
            "node": "Get All Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Alerts Needed": {
      "main": [
        [
          {
            "node": "Format Alert Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Low Stock Items": {
      "main": [
        [
          {
            "node": "Check if Alerts Needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 杂项

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量10
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

外部链接
在 n8n.io 查看

分享此工作流