Suivi quotidien des dépenses publicitaires : Google Sheets et alertes de seuil Slack

Intermédiaire

Ceci est unContent Creation, Multimodal AIworkflow d'automatisation du domainecontenant 13 nœuds.Utilise principalement des nœuds comme If, Set, Code, Slack, Summarize. Suivi des dépenses publicitaires quotidiennes avec Google Sheets et alertes de seuil Slack

Prérequis
  • Token Bot Slack ou URL Webhook
  • Informations d'identification Google Sheets API
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "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": "Planifier le Workflow",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -80,
        600
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bd446d05-bbcf-43de-8b41-25aa616d2965",
      "name": "Obtenir les données",
      "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": "Somme des dépenses par jour",
      "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": "Trier les dates par ordre décroissant",
      "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": "Conserver uniquement le dernier jour",
      "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": "Vérifier si les dépenses dépassent 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": "Envoyer le message Slack",
      "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": "Ne rien faire. Moins de 100",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1460,
        700
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0697878b-7728-4d5b-a90e-ef30b6869089",
      "name": "Note adhésive",
      "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": "Note adhésive 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": "Note adhésive 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": "Note adhésive 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": {
    "bd446d05-bbcf-43de-8b41-25aa616d2965": {
      "main": [
        [
          {
            "node": "071b0019-cc7f-4f44-9d33-00ee1a89d110",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0ae2c8b2-5526-4254-84e2-9bb038e1ffc0": {
      "main": [
        [
          {
            "node": "bd446d05-bbcf-43de-8b41-25aa616d2965",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "071b0019-cc7f-4f44-9d33-00ee1a89d110": {
      "main": [
        [
          {
            "node": "82145ab3-6574-40ad-84b7-c9afc90eeb2d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7992326c-7084-44b2-b221-25054dce8772": {
      "main": [
        [
          {
            "node": "bd446d05-bbcf-43de-8b41-25aa616d2965",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d199be5a-18e2-4c3c-a72e-dc299a611a19": {
      "main": [
        [
          {
            "node": "4eca8fe3-333d-4383-8a49-4a5da44de415",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "82145ab3-6574-40ad-84b7-c9afc90eeb2d": {
      "main": [
        [
          {
            "node": "d199be5a-18e2-4c3c-a72e-dc299a611a19",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4eca8fe3-333d-4383-8a49-4a5da44de415": {
      "main": [
        [
          {
            "node": "0e2c1e71-36f1-4c8d-90c9-c25bd7565fd5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "92a59075-9fdf-42d3-aa35-9ed07c4cdc33",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire - Création de contenu, IA Multimodale

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds13
Catégorie2
Types de nœuds10
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
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.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34