{
  "nodes": [
    {
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "position": [
        230,
        710
      ],
      "parameters": {
        "functionCode": "// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\n\n// Loop over inputs and add a new field called 'myNewField' to the JSON of each one\nfor (item of items) {\n  \nvar type = \"Status\";\n// Acknowledged\nif ((item.json.body.alert.statusCode == 2)  && (item.json.body.eventType == 201)) {\n    type = \"Acknowledged\";\n}\n// Closed\nif ((item.json.body.alert.statusCode == 4) & (item.json.body.eventType == 201)) {\n    type = \"Closed\";\n}\n// New Alert\nif ((item.json.body.alert.statusCode == 1) & (item.json.body.eventType == 200)) {\n    type = \"New Alert\";\n}\n\n// No one on duty\nif ((item.json.body.alert.statusCode == 16) & (item.json.body.eventType == 201)) {\n    type = \"No one on duty\";\n}\n \n// Annotation\nvar annotation = \"\";\nif ((item.json.body.eventType == 203) & (item.json.body.annotation != undefined) ) {\n    type = \"Annotated\";\n    annotation = item.json.body.annotation.message;\n}\nif (annotation != \"\") {\n    annotation = \": \" + annotation;\n}\n \nvar username = \"System\";\nif (item.json.body.user != undefined) {\n    username = item.json.body.user.username;\n}\n \nvar data = type + \" by \" + username + annotation;\n \nitem.json.s4Status = data; //  + \": \" + JSON.stringify(item.json);\n\n\nitem.json.s4Up = false;\nif (type == \"Closed\") {\n  item.json.s4Up = true;\n}\n\n}\n\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn items;\n\n\n"
      },
      "typeVersion": 1,
      "id": "node-05b80966"
    },
    {
      "name": "Notion Trigger",
      "type": "n8n-nodes-base.notionTrigger",
      "disabled": true,
      "position": [
        230,
        210
      ],
      "parameters": {
        "event": "pageAddedToDatabase",
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 1
            }
          ]
        },
        "databaseId": "0f26823d-f509-43bb-b0e9-e9bb4ab91217"
      },
      "credentials": {
        "notionApi": "Notion"
      },
      "typeVersion": 1,
      "id": "node-e4745504"
    },
    {
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        50,
        710
      ],
      "webhookId": "95fd62c7-fc8c-4f6f-8441-bbf85a2da81a",
      "parameters": {
        "path": "95fd62c7-fc8c-4f6f-8441-bbf85a2da81a",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1,
      "id": "node-c7267eaf"
    },
    {
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "position": [
        230,
        710
      ],
      "parameters": {
        "functionCode": "// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\n\n// Loop over inputs and add a new field called 'myNewField' to the JSON of each one\nfor (item of items) {\n  \nvar type = \"Status\";\n// Acknowledged\nif ((item.json.body.alert.statusCode == 2)  && (item.json.body.eventType == 201)) {\n    type = \"Acknowledged\";\n}\n// Closed\nif ((item.json.body.alert.statusCode == 4) & (item.json.body.eventType == 201)) {\n    type = \"Closed\";\n}\n// New Alert\nif ((item.json.body.alert.statusCode == 1) & (item.json.body.eventType == 200)) {\n    type = \"New Alert\";\n}\n\n// No one on duty\nif ((item.json.body.alert.statusCode == 16) & (item.json.body.eventType == 201)) {\n    type = \"No one on duty\";\n}\n \n// Annotation\nvar annotation = \"\";\nif ((item.json.body.eventType == 203) & (item.json.body.annotation != undefined) ) {\n    type = \"Annotated\";\n    annotation = item.json.body.annotation.message;\n}\nif (annotation != \"\") {\n    annotation = \": \" + annotation;\n}\n \nvar username = \"System\";\nif (item.json.body.user != undefined) {\n    username = item.json.body.user.username;\n}\n \nvar data = type + \" by \" + username + annotation;\n \nitem.json.s4Status = data; //  + \": \" + JSON.stringify(item.json);\n\n\nitem.json.s4Up = false;\nif (type == \"Closed\") {\n  item.json.s4Up = true;\n}\n\n}\n\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn items;\n\n\n"
      },
      "typeVersion": 1,
      "id": "node-c7f0ac86"
    },
    {
      "name": "Notion Update",
      "type": "n8n-nodes-base.notion",
      "position": [
        420,
        710
      ],
      "parameters": {
        "pageId": "={{$node[\"Webhook\"].json[\"body\"][\"alert\"][\"externalEventId\"]}}",
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "{{ $credentials.key }}",
              "peopleValue": [],
              "textContent": "={{$node[\"Function\"].json[\"s4Status\"]}}",
              "relationValue": [],
              "multiSelectValue": []
            }
          ]
        }
      },
      "credentials": {
        "notionApi": "Notion"
      },
      "typeVersion": 1,
      "id": "node-d3a12b05"
    },
    {
      "name": "Interval",
      "type": "n8n-nodes-base.interval",
      "position": [
        50,
        380
      ],
      "parameters": {
        "interval": 20
      },
      "typeVersion": 1,
      "id": "node-3d3536c7"
    },
    {
      "name": "SIGNL4 Resolve",
      "type": "n8n-nodes-base.signl4",
      "position": [
        420,
        540
      ],
      "parameters": {
        "operation": "resolve",
        "externalId": "={{$node[\"Notion Read Open\"].json[\"id\"]}}"
      },
      "credentials": {
        "signl4Api": "SIGNL4"
      },
      "typeVersion": 1,
      "id": "node-23838153"
    },
    {
      "name": "SIGNL4 Alert",
      "type": "n8n-nodes-base.signl4",
      "position": [
        420,
        210
      ],
      "parameters": {
        "message": "=Machine Alert: {{$node[\"Notion Trigger\"].json[\"Name\"]}}",
        "additionalFields": {
          "title": "n8n Alert",
          "externalId": "={{$node[\"Notion Trigger\"].json[\"id\"]}}",
          "locationFieldsUi": {
            "locationFieldsValues": {
              "latitude": "52.3992137",
              "longitude": "13.0583823"
            }
          }
        }
      },
      "credentials": {
        "signl4Api": "SIGNL4"
      },
      "typeVersion": 1,
      "id": "node-31591f30"
    },
    {
      "name": "Notion Update Read",
      "type": "n8n-nodes-base.notion",
      "position": [
        570,
        380
      ],
      "parameters": {
        "pageId": "={{$node[\"Notion Read New\"].json[\"id\"]}}",
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "{{ $credentials.key }}",
              "peopleValue": [],
              "checkboxValue": true,
              "relationValue": [],
              "multiSelectValue": []
            }
          ]
        }
      },
      "credentials": {
        "notionApi": "Notion"
      },
      "typeVersion": 1,
      "id": "node-913b4e1e"
    },
    {
      "name": "Notion Read Open",
      "type": "n8n-nodes-base.notion",
      "position": [
        230,
        540
      ],
      "parameters": {
        "options": {
          "filter": {
            "multipleCondition": {
              "condition": {
                "and": [
                  {
                    "key": "{{ $credentials.key }}",
                    "condition": "equals",
                    "checkboxValue": true,
                    "multiSelectValue": []
                  },
                  {
                    "key": "{{ $credentials.key }}",
                    "condition": "equals",
                    "checkboxValue": true,
                    "multiSelectValue": []
                  }
                ]
              }
            }
          }
        },
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": "0f26823d-f509-43bb-b0e9-e9bb4ab91217"
      },
      "credentials": {
        "notionApi": "Notion"
      },
      "typeVersion": 1,
      "id": "node-6a7885e0"
    },
    {
      "name": "Notion Read New",
      "type": "n8n-nodes-base.notion",
      "position": [
        230,
        380
      ],
      "parameters": {
        "options": {
          "filter": {
            "multipleCondition": {
              "condition": {
                "and": [
                  {
                    "key": "{{ $credentials.key }}",
                    "condition": "equals",
                    "multiSelectValue": []
                  },
                  {
                    "key": "{{ $credentials.key }}",
                    "condition": "equals",
                    "multiSelectValue": []
                  }
                ]
              }
            }
          }
        },
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": "0f26823d-f509-43bb-b0e9-e9bb4ab91217"
      },
      "credentials": {
        "notionApi": "Notion"
      },
      "typeVersion": 1,
      "id": "node-5312aa50"
    },
    {
      "name": "Notion Update Final",
      "type": "n8n-nodes-base.notion",
      "position": [
        570,
        540
      ],
      "parameters": {
        "pageId": "={{$node[\"Notion Read Open\"].json[\"id\"]}}",
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "{{ $credentials.key }}",
              "peopleValue": [],
              "relationValue": [],
              "multiSelectValue": []
            }
          ]
        }
      },
      "credentials": {
        "notionApi": "Notion"
      },
      "typeVersion": 1,
      "id": "node-dfa852c2"
    },
    {
      "name": "SIGNL4 Alert 2",
      "type": "n8n-nodes-base.signl4",
      "position": [
        420,
        380
      ],
      "parameters": {
        "message": "=Machine Alert: {{$node[\"Notion Read New\"].json[\"Name\"]}}",
        "additionalFields": {
          "title": "n8n Alert",
          "externalId": "={{$node[\"Notion Read New\"].json[\"id\"]}}",
          "locationFieldsUi": {
            "locationFieldsValues": {
              "latitude": "52.3992137",
              "longitude": "13.0583823"
            }
          }
        }
      },
      "credentials": {
        "signl4Api": "SIGNL4"
      },
      "typeVersion": 1,
      "id": "node-01d9c84b"
    },
    {
      "id": "error-522abc77",
      "name": "Error Handler",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1000,
        400
      ],
      "parameters": {
        "message": "Workflow execution error",
        "options": {}
      }
    }
  ],
  "connections": {},
  "name": "Production Workflow",
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": null,
    "timezone": "UTC",
    "executionTimeout": 3600,
    "maxExecutions": 1000,
    "retryOnFail": true,
    "retryCount": 3
  },
  "meta": {
    "instanceId": "workflow-b34ff223",
    "versionId": "1.0.0",
    "createdAt": "2025-09-29T07:07:52.290421",
    "updatedAt": "2025-09-29T07:07:52.290435",
    "owner": "n8n-user",
    "license": "MIT",
    "category": "automation",
    "status": "active",
    "priority": "high",
    "environment": "production"
  },
  "tags": [
    "automation",
    "n8n",
    "production-ready",
    "excellent",
    "optimized"
  ],
  "description": "Production-ready workflow: Production Workflow. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."
}