{
  "id": "W9YdHiWv369VleZq",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Live Airport Delay Dashboard with FlightStats & Team Alerts",
  "tags": [],
  "nodes": [
    {
      "id": "0de5effa-4001-4595-97f8-50ab94ed98ec",
      "name": "Set Schedule",
      "type": "n8n-nodes-base.cron",
      "notes": "Triggers the workflow every hour to fetch live airport delay data automatically.",
      "position": [
        -1340,
        -140
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a320ec16-1594-4c79-ada4-4e96b4a266d5",
      "name": "FlightStats API",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Fetches live delay data from the FlightStats API for the specified airport (e.g., JFK) using the current hour.",
      "position": [
        -1120,
        -140
      ],
      "parameters": {
        "url": "https://api.flightstats.com/flex/delay/index",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "86377545-7486-4006-962c-879a5fefc400",
      "name": "Set Output Data",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Stores the fetched delay data (airport code and delay minutes) into a Google Sheet for display.",
      "position": [
        -900,
        -140
      ],
      "parameters": {
        "range": "A:B",
        "options": {},
        "sheetId": "your_sheet_id",
        "operation": "append"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2062807e-c0c6-4242-97aa-75482fb6f156",
      "name": "Merge API Data",
      "type": "n8n-nodes-base.if",
      "notes": "Checks if the delay exceeds 30 minutes to determine if a severe delay alert is needed.",
      "position": [
        -680,
        -140
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "{{$node['FlightStats API'].json['delayMinutes']}}",
              "value2": 30,
              "operation": "greater"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1075857c-14dd-4a0f-b99f-a4dce935eca9",
      "name": "Send Response via Slack",
      "type": "n8n-nodes-base.slack",
      "notes": "Sends a Slack alert to the 'ops-sales' channel if a severe delay is detected, including airport and delay details.",
      "position": [
        -460,
        -240
      ],
      "parameters": {
        "text": "\ud83d\udea8 Severe Delay Alert: {{$node['FlightStats API'].json['airportCode']}} has a delay of {{$node['FlightStats API'].json['delayMinutes']} minutes at {{$now.toISOString()}}",
        "channel": "ops-sales",
        "attachments": [],
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e78cdfc5-cd5d-4d73-ae53-7facc1ce6863",
      "name": "No Action for Minor Delays",
      "type": "n8n-nodes-base.noOp",
      "notes": "Placeholder node for delays under 30 minutes, where no alert is sent.",
      "position": [
        -460,
        -40
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "67f1aa9a-8e43-4df1-9fee-08433f477a2e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1380,
        -560
      ],
      "parameters": {
        "width": 560,
        "height": 280,
        "content": "## System Architecture\n- **Delay Monitoring Pipeline**:\n  - **Set Schedule**: Triggers the workflow hourly or daily via Cron.\n  - **FlightStats API**: Retrieves live airport delay data.\n- **Data Management Flow**:\n  - **Set Output Data**: Prepares data for storage or display.\n  - **Merge API Data**: Combines and processes delay data.\n- **Alert and Display**:\n  - **Send Response via Slack**: Alerts ops/sales for severe delays.\n  - **No Action for Minor Delays**: Skips minor delays with no action."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f93f1a65-e793-481d-9b9f-4514a3b81655",
  "connections": {
    "Set Schedule": {
      "main": [
        [
          {
            "node": "FlightStats API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge API Data": {
      "main": [
        [
          {
            "node": "Send Response via Slack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Action for Minor Delays",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FlightStats API": {
      "main": [
        [
          {
            "node": "Set Output Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Output Data": {
      "main": [
        [
          {
            "node": "Merge API Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}