8
n8n 中文网amn8n.com

每日广告支出监控:Google表格和Slack阈值提醒

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 If, Set, Code, Slack, Summarize 等节点。 使用Google表格和Slack阈值提醒的每日广告支出监控

前置要求
  • Slack Bot Token 或 Webhook URL
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439"
  },
  "nodes": [
    {
      "id": "0ae2c8b2-5526-4254-84e2-9bb038e1ffc0",
      "name": "Test Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -80,
        420
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7992326c-7084-44b2-b221-25054dce8772",
      "name": "Schedule Workflow",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -80,
        600
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bd446d05-bbcf-43de-8b41-25aa616d2965",
      "name": "获取数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        200,
        480
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk",
          "cachedResultName": "Sample Marketing Data"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "071b0019-cc7f-4f44-9d33-00ee1a89d110",
      "name": "Sum spend by Day",
      "type": "n8n-nodes-base.summarize",
      "position": [
        540,
        400
      ],
      "parameters": {
        "options": {},
        "fieldsToSplitBy": "Date",
        "fieldsToSummarize": {
          "values": [
            {
              "field": "Spend ($)",
              "aggregation": "sum"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "82145ab3-6574-40ad-84b7-c9afc90eeb2d",
      "name": "Sort Dates Descending",
      "type": "n8n-nodes-base.code",
      "position": [
        740,
        600
      ],
      "parameters": {
        "jsCode": "// 1. Grab all incoming items\nconst items = $input.all();\n\n// 2. Sort by your date field descending\nitems.sort((a, b) => {\n  const da = new Date(a.json.Date).getTime();\n  const db = new Date(b.json.Date).getTime();\n  return db - da;  // newest first\n});\n\n// 3. Return sorted items\nreturn items;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d199be5a-18e2-4c3c-a72e-dc299a611a19",
      "name": "Keep only Last Day",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        380
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e98f13e6-20a4-49fc-87cd-5b20f54f010c",
              "name": "Date",
              "type": "string",
              "value": "={{ $json.Date }}"
            },
            {
              "id": "a127b49d-dbfb-4143-a944-10d6e95e4e04",
              "name": "sum_Spend_($)",
              "type": "number",
              "value": "={{ $json['sum_Spend_($)'] }}"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "4eca8fe3-333d-4383-8a49-4a5da44de415",
      "name": "Check if Spend over $100",
      "type": "n8n-nodes-base.if",
      "position": [
        1180,
        580
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6193ed35-58eb-4ca3-a0a2-9f0426ecce5e",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json['sum_Spend_($)'] }}",
              "rightValue": 100
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0e2c1e71-36f1-4c8d-90c9-c25bd7565fd5",
      "name": "Send Slack Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        1420,
        500
      ],
      "webhookId": "8f1ab338-1546-42f8-b6ae-3cd344d5faf3",
      "parameters": {
        "text": "The spend for the most recent day is over  $100",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C08T2J84F6C",
          "cachedResultName": "leads"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "keV27N1Uk30CvNXL",
          "name": "Slack account"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "92a59075-9fdf-42d3-aa35-9ed07c4cdc33",
      "name": "Do Nothign. Under 100",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1460,
        700
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0697878b-7728-4d5b-a90e-ef30b6869089",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -200
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 1000,
        "content": "#### 1️⃣ Schedule or Manual Trigger\n- **Node**: `Schedule Workflow` or `Test Workflow`\n- **Purpose**: Either run daily via a cron-like rule or manually trigger the flow.\n\n#### 2️⃣ Get Google Sheet Data\n- **Node**: `Get Data`\n- **What it does**: Fetches all rows from your connected sheet.\n- **Setup**:\n  - Go to [Google Cloud Console](https://console.cloud.google.com/)\n  - Create a new project\n  - Enable **Google Sheets API**\n  - Create OAuth2 credentials for a desktop or web application\n  - Connect your Google account in n8n via OAuth2\n  - Grant access to the sheet you want to read (ensure it's shared with your OAuth email)\n  - Use the copied sheet's link when connecting in n8n\n\n📎 **Copy this Sample Google Sheet to Use:**  \n[Marketing Data Sheet - Copy Me](https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=sharing)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0be15add-86ff-419e-bacb-64984e429429",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -200
      ],
      "parameters": {
        "color": 6,
        "width": 600,
        "height": 1000,
        "content": "#### 3️⃣ Summarize Spend by Day\n- **Node**: `Sum spend by Day`\n- **What it does**: Groups the dataset by `Date` and sums the `Spend ($)` column\n- **Requirements**:\n  - Your sheet must have a header row with `Date` and `Spend ($)` as columns\n\n#### 4️⃣ Sort by Most Recent Date\n- **Node**: `Sort Dates Descending`\n- **What it does**: Sorts all entries by the `Date` field so that the most recent day is first\n- **Custom JavaScript**:\n```js\nconst items = $input.all();\nitems.sort((a, b) => new Date(b.json.Date) - new Date(a.json.Date));\nreturn items;\n```\n\n#### 5️⃣ Select Top Result\n- **Node**: `Keep only Last Day`\n- **What it does**: Captures the top row (most recent day) for evaluation\n- **Fields**: Sets only `Date` and `sum_Spend_($)` to keep things clean"
      },
      "typeVersion": 1
    },
    {
      "id": "1a496e73-eaf8-427b-aee3-c1f8303f0f6d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -200
      ],
      "parameters": {
        "color": 3,
        "width": 540,
        "height": 1000,
        "content": "#### 6️⃣ Check Spend Threshold\n- **Node**: `Check if Spend over $100`\n- **What it does**: Uses an IF node to compare `sum_Spend_($)` against a 100 threshold\n- **Logic**:\n```json\nsum_Spend_($) > 100\n```\n\n#### 7️⃣ Send Slack Notification\n- **Node**: `Send Slack Message`\n- **What it does**: Sends a message to a Slack channel if the threshold is exceeded\n- **Setup**:\n  - Go to [Slack API](https://api.slack.com/apps)\n  - Create a new app\n  - Enable **chat:write** and **channels:read** scopes under OAuth & Permissions\n  - Install the app to your workspace\n  - Copy the OAuth Token into your Slack credentials in n8n\n  - Select your target channel from the dropdown (must be public or the bot must be invited)\n- **Message**:\n  ```\n  The spend for the most recent day is over $100\n  ```\n\n#### 8️⃣ No Action if Under Budget\n- **Node**: `Do Nothing. Under 100`\n- **Purpose**: This path simply ends the flow with no action if spend is below the threshold\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0c4f9160-7700-4b90-9766-d10ad829947c",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -360
      ],
      "parameters": {
        "width": 1780,
        "height": 120,
        "content": "### 👤 Need more help?\n**Robert Breen**  \nAutomation Consultant | AI Workflow Designer | n8n Expert  \n📧 [robert@ynteractive.com](mailto:robert@ynteractive.com)  \n🔗 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Get Data": {
      "main": [
        [
          {
            "node": "Sum spend by Day",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Workflow": {
      "main": [
        [
          {
            "node": "Get Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sum spend by Day": {
      "main": [
        [
          {
            "node": "Sort Dates Descending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Workflow": {
      "main": [
        [
          {
            "node": "Get Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep only Last Day": {
      "main": [
        [
          {
            "node": "Check if Spend over $100",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sort Dates Descending": {
      "main": [
        [
          {
            "node": "Keep only Last Day",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Spend over $100": {
      "main": [
        [
          {
            "node": "Send Slack Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Do Nothign. Under 100",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 查看

分享此工作流