image.png

n8n-Workflow

{
  "name": "Google Ads Script Webhook",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "DEIN_WEBHOOK_PFAD_HIER",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        -208
      ],
      "id": "aaf5da47-b5f5-49c4-bf3c-c440e1a91857",
      "name": "Webhook",
      "webhookId": "DEINE_WEBHOOK_ID_HIER"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "DEINE_SLACK_CHANNEL_ID_HIER",
          "mode": "list",
          "cachedResultName": "dein-slack-channel"
        },
        "messageType": "block",
        "blocksUi": "=🚨 Alarm: {{ $json.body.script_name }} \nAccount: {{ $json.body.account_id }} \nFehler: {{ $json.body.message }}",
        "text": "={{ $json.slackMessage.text }}",
        "otherOptions": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        448,
        -112
      ],
      "id": "ab7738ad-3135-4938-8d8c-f8ea95a06057",
      "name": "Send a message",
      "webhookId": "DEINE_SLACK_WEBHOOK_ID_HIER",
      "credentials": {
        "slackOAuth2Api": {
          "id": "DEINE_SLACK_CREDENTIAL_ID_HIER",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.status }}",
                    "rightValue": "ERROR",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "6ea8283b-7c64-47e1-a9a3-fafd761b5c45"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "ERROR"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "58099616-9756-4a46-9aca-382b5ccfedcd",
                    "leftValue": "={{ $json.body.status }}",
                    "rightValue": "CRITICAL",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "CRITICAL"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "16842366-d298-4552-afb4-e488e48fb06f",
                    "leftValue": "={{ $json.body.status }}",
                    "rightValue": "SUCCESS",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "SUCCESS"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "aa2bc267-9d11-4816-be9d-cde1453bc6f5",
                    "leftValue": "={{ $json.body.status }}",
                    "rightValue": "OPTIMIZE",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "OPTIMIZE"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        224,
        -240
      ],
      "id": "c656fe7d-aa37-48d4-a722-4e08df2fa676",
      "name": "Switch"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "DEINE_SHEET_ID_HIER",
          "mode": "list",
          "cachedResultName": "Dein n8n Script Logging Sheet",
          "cachedResultUrl": "<https://docs.google.com/spreadsheets/d/DEINE_SHEET_ID_HIER/edit?usp=drivesdk>"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Tabellenblatt1",
          "cachedResultUrl": "<https://docs.google.com/spreadsheets/d/DEINE_SHEET_ID_HIER/edit#gid=0>"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Script Name": "={{ $('Webhook').item.json.body.script_name }}",
            "Status": "={{ $('Webhook').item.json.body.status }}",
            "Account ID": "={{ $('Webhook').item.json.body.account_id }}",
            "Message": "={{ $('Webhook').item.json.body.message }}",
            "Timestamp": "={{ $('Webhook').item.json.body.timestamp }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Timestamp",
              "displayName": "Timestamp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Script Name",
              "displayName": "Script Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Account ID",
              "displayName": "Account ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message",
              "displayName": "Message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        448,
        -304
      ],
      "id": "7e732dae-9051-4c49-9edf-f6f5633f90f6",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "DEINE_GSHEETS_CREDENTIAL_ID_HIER",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Eingang: Script-Logs\nEmpfängt Status-Updates, Fehlermeldungen und Performance-Daten von Google Ads Scripts via POST-Request."
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -80,
        -480
      ],
      "id": "a03bdf5f-8515-4abc-8e39-34060f821e51",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Filter & Routing\nPrüft den status des Payloads. Alle Events werden geloggt, aber nur kritische Fehler lösen einen Alarm aus.",
        "width": 208,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        176,
        -480
      ],
      "id": "d4a6f465-b970-45f6-9669-99ca17855fe7",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## 🚨 Alerting \n(nur bei CRITICAL)\nSendet sofortige Benachrichtigung in den Slack-Channel mit Details zu Account und Fehlermeldung."
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        416,
        48
      ],
      "id": "4cf7f50f-c48a-4006-8a0e-aeb3d54df1c9",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Zentrales Logging\n(Google Sheets) \nSchreibt jeden Durchlauf (Success, Error, Optimize) in die Tabelle 'n8n Script Logging' zur späteren Analyse und Reporting."
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        400,
        -480
      ],
      "id": "b9cec477-9c9f-417f-9f0d-fd57bbd9f449",
      "name": "Sticky Note3"
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Append row in sheet": {
      "main": [
        []
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "PLATZHALTER_VERSION_ID",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "DEINE_N8N_INSTANCE_ID_HIER"
  },
  "id": "PLATZHALTER_WORKFLOW_ID",
  "tags": []
}