{
  "schema_version": "1.0.0",
  "id": "ad-spend-over-budget",
  "title": "Flag a day's ad spend that runs 20% over budget",
  "category": "reporting",
  "difficulty": "beginner",
  "featured": false,
  "description": "When the daily ad spend export adds a row, compute the percent over budget with Formatter and alert Slack if it is more than 20.",
  "tags": [
    "ads",
    "budget",
    "google-sheets",
    "formatter",
    "slack"
  ],
  "apps": [
    "Google Sheets",
    "Formatter by Zapier",
    "Filter by Zapier",
    "Slack"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger",
      "Filter by Zapier",
      "Formatter by Zapier"
    ]
  },
  "tasks": {
    "typical": 0,
    "max": 1
  },
  "trigger": {
    "app": "Google Sheets",
    "event": "New Spreadsheet Row",
    "kind": "polling",
    "title": "New daily spend row",
    "why": "Fires for each new row the daily export appends: one per campaign per day.",
    "config": {
      "Drive": "My Google Drive",
      "Spreadsheet": "Ad spend",
      "Worksheet": "Daily"
    },
    "outputs": [
      "row_number",
      "date",
      "channel",
      "campaign",
      "spend",
      "daily_budget"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "pct",
      "kind": "formatter",
      "app": "Formatter by Zapier",
      "event": "Numbers",
      "title": "Work out the percent over budget",
      "why": "A spreadsheet-style formula in Formatter avoids a Code step and costs no task.",
      "fields": {
        "Transform": "Spreadsheet-Style Formula",
        "Formula": "ROUND(({{trigger.spend}} - {{trigger.daily_budget}}) / {{trigger.daily_budget}} * 100, 1)"
      },
      "outputs": [
        "output"
      ]
    },
    {
      "key": "over",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only campaigns more than 20% over",
      "why": "Most days most campaigns are on budget, so most rows stop here.",
      "conditions": [
        [
          {
            "field": "{{pct.output}}",
            "operator": "(Number) Greater than",
            "value": "20"
          }
        ]
      ],
      "usually": false
    },
    {
      "key": "alert",
      "kind": "action",
      "app": "Slack",
      "event": "Send Channel Message",
      "title": "Alert the marketing channel",
      "why": "Names the campaign, the channel, and the overspend so the owner can pause it.",
      "fields": {
        "Channel": "#marketing",
        "Message Text": ":chart_with_upwards_trend: {{trigger.campaign}} on {{trigger.channel}} spent {{trigger.spend}} against a {{trigger.daily_budget}} budget on {{trigger.date}} ({{pct.output}}% over).",
        "Send as a bot?": "Yes",
        "Bot Name": "Zap alerts",
        "Include a link to this Zap?": "No"
      },
      "outputs": [
        "ts",
        "permalink"
      ]
    }
  ]
}
