{
  "name": "Crypto Price Monitor + Telegram Alert",
  "nodes": [
    {
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd",
        "options": {}
      },
      "id": "http",
      "name": "Fetch Prices",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\nconst threshold = 60000; // BTC threshold\nconst btcPrice = data.bitcoin.usd;\nif (btcPrice > threshold) {\n  return { alert: true, coin: 'Bitcoin', price: btcPrice, threshold };\n}\nreturn { alert: false };"
      },
      "id": "check",
      "name": "Check Threshold",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\nif (!item.alert) return [];\nreturn [{json: {text: `\ud83d\udea8 ${item.coin} is at $${item.price.toLocaleString()} \u2014 above your $${item.threshold.toLocaleString()} alert!`}}];"
      },
      "id": "filter",
      "name": "Only Alerts",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "chatId": "",
        "text": "={{ $json.text }}"
      },
      "id": "telegram",
      "name": "Telegram Alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Fetch Prices": {
      "main": [
        [
          {
            "node": "Check Threshold",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Threshold": {
      "main": [
        [
          {
            "node": "Only Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only Alerts": {
      "main": [
        [
          {
            "node": "Telegram Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}