{
  "id": "4mPddx6U7hy5pWH7",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Emergency Alert Workflow for Schools \u2013 Notify Parents & Staff Instantly",
  "tags": [],
  "nodes": [
    {
      "id": "bd9ad6da-4889-4c8c-9b74-fdff1e354c3c",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "notes": "This node triggers the workflow when an emergency alert is received via a POST request, containing details like emergency type and contact list.",
      "position": [
        -100,
        40
      ],
      "parameters": {
        "path": "emergency-alert",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "cc9f3fab-65c6-44bf-bb45-3ad892b71e58",
      "name": "Filter Emergency Alerts",
      "type": "n8n-nodes-base.if",
      "notes": "This IF node checks if the incoming alert is marked as 'active'. Only active emergencies proceed to notification steps.",
      "position": [
        120,
        40
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "{{$node['Webhook Trigger'].json['status']}}",
              "value2": "active"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c65af54d-c920-4662-8e37-72f764355358",
      "name": "Send Email Alert",
      "type": "n8n-nodes-base.emailSend",
      "notes": "Sends an email alert to parents and staff with emergency details. Update 'your_email@example.com' with your sender email and configure SMTP credentials.",
      "position": [
        340,
        -160
      ],
      "parameters": {
        "text": "Dear Parents and Staff,\n\nAn emergency ({{$node['Webhook Trigger'].json['emergencyType'] || 'Unknown Emergency'}}) is active. Please follow safety protocols. Details: {{$node['Webhook Trigger'].json['details'] || 'No additional details'}}.\n\nStay safe,\nSchool Administration",
        "options": {},
        "subject": "\ud83d\udea8 Emergency Alert: {{$node['Webhook Trigger'].json['emergencyType'] || 'Unknown Emergency'}}",
        "toEmail": "{{$node['Webhook Trigger'].json['contactList'] || 'default_emails@example.com'}}",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c5a51229-55f2-4dad-a439-7105d4224b90",
      "name": "Send Slack Alert",
      "type": "n8n-nodes-base.slack",
      "notes": "Sends a Slack notification to the 'emergency' channel with emergency details for staff coordination.",
      "position": [
        340,
        40
      ],
      "parameters": {
        "text": "\ud83d\udea8 Emergency Alert: {{$node['Webhook Trigger'].json['emergencyType'] || 'Unknown Emergency'}} \nDetails: {{$node['Webhook Trigger'].json['details'] || 'No additional details'}} \nContact List: {{$node['Webhook Trigger'].json['contactList'] || 'Not specified'}}",
        "channel": "emergency",
        "attachments": [],
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d25f17a0-a2a7-4955-9cbd-3793cff662ca",
      "name": "No Action for Inactive",
      "type": "n8n-nodes-base.noOp",
      "notes": "This node is a placeholder for when the alert is not active. No action is taken if the status is not 'active'.",
      "position": [
        340,
        240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4ed251d3-55ea-48b5-b1a7-24d3857be124",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -340
      ],
      "parameters": {
        "color": 3,
        "width": 760,
        "height": 280,
        "content": "## System Architecture\n- **Emergency Detection Pipeline**:\n  - **Webhook Trigger**: Captures incoming emergency alerts via POST requests.\n  - **Filter Emergency Alerts**: Identifies active emergencies.\n- **Notification Generation Flow**:\n  - **Send Email Alert**: Notifies parents and staff via email.\n  - **Send Slack Alert**: Alerts staff via Slack for coordination.\n- **Non-Emergency Handling**:\n  - **No Action for Inactive**: Skips inactive alerts with no further action.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f8cf81e8-7ac8-4a31-bd15-4f9f08f43f33",
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Filter Emergency Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Emergency Alerts": {
      "main": [
        [
          {
            "node": "Send Email Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Slack Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Action for Inactive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}