{
  "id": "T3nT9lGG91jxyLsK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Travel Supplier Monitor: Track API Health, Uptime & SLA Compliance Automatically",
  "tags": [],
  "nodes": [
    {
      "id": "2a498c6b-abc3-46dd-8acc-5ee0c24570d3",
      "name": "Monitor Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1740,
        -380
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 10
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "677cb112-dc2f-43e6-b1ee-68728d8ae773",
      "name": "Amadeus Flight API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1520,
        -480
      ],
      "parameters": {
        "url": "https://api.amadeus.com/v1/reference-data/airlines",
        "options": {
          "timeout": 8000,
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "TravelMonitor/1.0"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "d4fc7dbe-d36d-49cb-bab0-25bce07ea6be",
      "name": "Booking Hotel API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1520,
        -280
      ],
      "parameters": {
        "url": "https://distribution-xml.booking.com/",
        "options": {
          "timeout": 8000,
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "TravelMonitor/1.0"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "ffe8eb40-5fa7-4d7c-8055-2c6aa780d209",
      "name": "Calculate Health & SLA",
      "type": "n8n-nodes-base.code",
      "position": [
        -1300,
        -380
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst timestamp = new Date().toISOString();\nconst results = [];\n\n// Supplier configurations\nconst suppliers = [\n  { name: 'Amadeus', type: 'Flight API', slaTarget: 99.5 },\n  { name: 'Booking.com', type: 'Hotel API', slaTarget: 99.0 }\n];\n\nfor (let i = 0; i < items.length; i++) {\n  const item = items[i].json;\n  const supplier = suppliers[i];\n  const statusCode = item.statusCode || 0;\n  const isHealthy = statusCode >= 200 && statusCode < 300;\n  const responseTime = item.headers ? 200 : 5000; // Simulated\n  \n  // Calculate uptime percentage (simplified)\n  const uptimePercentage = isHealthy ? 100 : 0;\n  \n  // SLA compliance check\n  const slaCompliant = uptimePercentage >= supplier.slaTarget;\n  const slaStatus = slaCompliant ? '\u2705 COMPLIANT' : '\u274c BREACH';\n  \n  // Health status\n  const healthStatus = isHealthy ? '\ud83d\udfe2 HEALTHY' : '\ud83d\udd34 DOWN';\n  \n  // Performance rating\n  let performance;\n  if (responseTime < 500 && isHealthy) performance = '\u26a1 EXCELLENT';\n  else if (responseTime < 2000 && isHealthy) performance = '\u2705 GOOD';\n  else if (responseTime < 5000 && isHealthy) performance = '\u26a0\ufe0f AVERAGE';\n  else performance = '\u274c POOR';\n  \n  results.push({\n    supplier_name: supplier.name,\n    api_type: supplier.type,\n    timestamp: timestamp,\n    status_code: statusCode,\n    health_status: healthStatus,\n    is_healthy: isHealthy,\n    response_time_ms: responseTime,\n    uptime_percentage: uptimePercentage,\n    sla_target: supplier.slaTarget,\n    sla_status: slaStatus,\n    sla_compliant: slaCompliant,\n    performance_rating: performance,\n    alert_required: !slaCompliant\n  });\n}\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "9959f0f0-1954-4e0d-951b-e927c76f1105",
      "name": "Alert Check",
      "type": "n8n-nodes-base.if",
      "position": [
        -1080,
        -380
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "condition1",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.alert_required }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "264ce28a-d467-4c86-8e61-1bc9df4e3083",
      "name": "SLA Breach Alert",
      "type": "n8n-nodes-base.debugHelper",
      "position": [
        -860,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "50c22357-03a5-480e-9577-642056a97aaa",
      "name": "Normal Status Log",
      "type": "n8n-nodes-base.debugHelper",
      "position": [
        -860,
        -280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "25b1db91-172f-44fc-aee7-b156ae64d486",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1765,
        -480
      ],
      "parameters": {
        "color": 3,
        "width": 150,
        "height": 260,
        "content": "Runs every 10 minutes automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "f4710764-e7a0-4775-b09e-d8f67babd434",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1105,
        -480
      ],
      "parameters": {
        "color": 4,
        "width": 150,
        "height": 260,
        "content": "Routes to appropriate responses based on breach status."
      },
      "typeVersion": 1
    },
    {
      "id": "0f7024e0-bddd-4433-a2f9-c83d53c25fba",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1325,
        -480
      ],
      "parameters": {
        "color": 5,
        "width": 150,
        "height": 260,
        "content": "Processes health, uptime, and SLA data."
      },
      "typeVersion": 1
    },
    {
      "id": "efbc2758-2168-4f75-aeed-6036281a4bfd",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -885,
        -660
      ],
      "parameters": {
        "color": 2,
        "width": 150,
        "height": 540,
        "content": "Records results, with alerts for breaches and normal logs for healthy status."
      },
      "typeVersion": 1
    },
    {
      "id": "09e1b313-1b20-456c-818a-a4523a443fb3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1545,
        -660
      ],
      "parameters": {
        "width": 150,
        "height": 540,
        "content": "Tests both the Amadeus Flight API and Booking.com Hotel API simultaneously."
      },
      "typeVersion": 1
    },
    {
      "id": "d21648ba-de83-47fc-bc79-f6c1e87440c5",
      "name": "Send message",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -640,
        -380
      ],
      "parameters": {
        "textBody": "{{json.logs}}",
        "operation": "send",
        "phoneNumberId": "=+91999876667877",
        "additionalFields": {},
        "recipientPhoneNumber": "+1234567890"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f9e4e3f9-2cdf-406e-aed1-1bd4358852cb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        -480
      ],
      "parameters": {
        "color": 6,
        "width": 150,
        "height": 260,
        "content": "Sends a WhatsApp message for breach alerts."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d4c14b4f-2bee-4cae-a443-49a0f6a2fff6",
  "connections": {
    "Alert Check": {
      "main": [
        [
          {
            "node": "SLA Breach Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Normal Status Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monitor Schedule": {
      "main": [
        [
          {
            "node": "Amadeus Flight API",
            "type": "main",
            "index": 0
          },
          {
            "node": "Booking Hotel API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SLA Breach Alert": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Booking Hotel API": {
      "main": [
        [
          {
            "node": "Calculate Health & SLA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normal Status Log": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Amadeus Flight API": {
      "main": [
        [
          {
            "node": "Calculate Health & SLA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Health & SLA": {
      "main": [
        [
          {
            "node": "Alert Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}