{
  "name": "02 - Triggers and Webhooks",
  "nodes": [
    {
      "parameters": {
        "content": "## 02 Triggers and Webhooks\nClick Listen for test event on the Webhook, then run:\n\ncurl -X POST <TEST_URL> -H \"Content-Type: application/json\" -d '{\"build\":\"#42\",\"branch\":\"main\",\"status\":\"failed\"}'\n\nChange status to passed and run again.\nBottom flow: Schedule Trigger runs daily at 2 AM once the workflow is active.",
        "height": 260,
        "width": 520
      },
      "id": "02000000-0000-4000-8000-000000000000",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-60, -320]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "build-status",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "02000000-0000-4000-8000-000000000001",
      "name": "CI Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0],
      "webhookId": "0b2c3d4e-0202-4a2b-9c3d-7e8f9a0b1c02"
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "loose", "version": 2 },
          "conditions": [
            {
              "id": "02a00000-0000-4000-8000-000000000001",
              "leftValue": "={{ $json.body.status }}",
              "rightValue": "failed",
              "operator": { "type": "string", "operation": "equals" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "02000000-0000-4000-8000-000000000002",
      "name": "Build Failed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { alert: true, message: 'Build ' + $json.body.build + ' FAILED on ' + $json.body.branch } }}",
        "options": {}
      },
      "id": "02000000-0000-4000-8000-000000000003",
      "name": "Respond: Alert",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [460, -100]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { alert: false, message: 'Build ' + $json.body.build + ' passed' } }}",
        "options": {}
      },
      "id": "02000000-0000-4000-8000-000000000004",
      "name": "Respond: OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [460, 100]
    },
    {
      "parameters": {
        "rule": { "interval": [{ "field": "cronExpression", "expression": "0 2 * * *" }] }
      },
      "id": "02000000-0000-4000-8000-000000000005",
      "name": "Nightly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "02a00000-0000-4000-8000-000000000002",
              "name": "message",
              "value": "=Nightly regression check fired at {{ $now.toFormat('yyyy-MM-dd HH:mm') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "02000000-0000-4000-8000-000000000006",
      "name": "Nightly Message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [220, 300]
    }
  ],
  "connections": {
    "CI Webhook": { "main": [[{ "node": "Build Failed?", "type": "main", "index": 0 }]] },
    "Build Failed?": {
      "main": [
        [{ "node": "Respond: Alert", "type": "main", "index": 0 }],
        [{ "node": "Respond: OK", "type": "main", "index": 0 }]
      ]
    },
    "Nightly Schedule": { "main": [[{ "node": "Nightly Message", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "active": false
}
