{
  "schema_version": "1.0.0",
  "id": "low-stock-supplier-email",
  "title": "Email the supplier when a stock row drops below reorder point",
  "category": "ecommerce",
  "difficulty": "beginner",
  "featured": false,
  "description": "When an inventory sheet row falls below its reorder point, email the supplier a reorder request and tell the team in Slack.",
  "tags": [
    "inventory",
    "reorder",
    "google-sheets",
    "gmail",
    "suppliers"
  ],
  "apps": [
    "Google Sheets",
    "Filter by Zapier",
    "Gmail",
    "Slack"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger",
      "Filter by Zapier"
    ]
  },
  "tasks": {
    "typical": 0,
    "max": 2
  },
  "trigger": {
    "app": "Google Sheets",
    "event": "New or Updated Spreadsheet Row",
    "kind": "polling",
    "title": "Stock count changed",
    "why": "Fires when the on_hand cell of a row changes, which is what a stock count or a sale does.",
    "config": {
      "Drive": "My Google Drive",
      "Spreadsheet": "Inventory",
      "Worksheet": "Stock",
      "Trigger Column": "on_hand"
    },
    "outputs": [
      "row_number",
      "sku",
      "product",
      "on_hand",
      "reorder_point",
      "reorder_qty",
      "below_reorder",
      "supplier_name",
      "supplier_email"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "low",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only rows below their reorder point",
      "why": "The sheet's `below_reorder` column does the comparison with a formula, so the filter only has to read yes or no.",
      "conditions": [
        [
          {
            "field": "{{trigger.below_reorder}}",
            "operator": "(Text) Exactly matches",
            "value": "yes"
          },
          {
            "field": "{{trigger.supplier_email}}",
            "operator": "Exists"
          }
        ]
      ],
      "usually": false
    },
    {
      "key": "order",
      "kind": "action",
      "app": "Gmail",
      "event": "Send Email",
      "title": "Email the supplier",
      "why": "A plain reorder request with the SKU and quantity the sheet already holds.",
      "fields": {
        "To": "{{trigger.supplier_email}}",
        "Subject": "Reorder: {{trigger.product}} ({{trigger.sku}})",
        "Body Type": "plain",
        "Body": "Hello {{trigger.supplier_name}},\n\nPlease send {{trigger.reorder_qty}} units of {{trigger.product}} (our SKU {{trigger.sku}}). We are down to {{trigger.on_hand}}.\n\nReply with the expected delivery date and we will confirm.\n\nThanks,\nYOUR_NAME",
        "From Name": "YOUR_BUSINESS_NAME purchasing"
      },
      "outputs": [
        "id",
        "thread_id"
      ]
    },
    {
      "key": "tell",
      "kind": "action",
      "app": "Slack",
      "event": "Send Channel Message",
      "title": "Tell the team it is ordered",
      "why": "Stops a second person from ordering the same thing by hand.",
      "fields": {
        "Channel": "#inventory",
        "Message Text": ":package: Reorder sent to {{trigger.supplier_name}} for {{trigger.reorder_qty}} x {{trigger.product}} (on hand: {{trigger.on_hand}}).",
        "Send as a bot?": "Yes",
        "Bot Name": "Zap alerts",
        "Include a link to this Zap?": "No"
      },
      "outputs": [
        "ts",
        "permalink"
      ]
    }
  ]
}
