{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5695a0ca-3750-4d6f-bbb3-d41143375841",
      "name": "Every 15 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "0535cf1e-d5de-47da-9962-0aa1a7524db8",
      "name": "Get Crypto Prices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        0
      ],
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd&include_24hr_change=true",
        "options": {}
      },
      "typeVersion": 4.1
    },
    {
      "id": "33914e7a-c4bc-40aa-b2e9-ac8e41d3e4ab",
      "name": "Compute Threshold Flags",
      "type": "n8n-nodes-base.code",
      "position": [
        432,
        0
      ],
      "parameters": {
        "jsCode": "const BTC_UP=110000, BTC_DOWN=105000, ETH_UP=4500, ETH_DOWN=4200, MOVE_ABS=2.0;\nconst j=$json; const now=new Date().toISOString();\nconst btcPrice=Number(j.bitcoin?.usd), btcChg=Number(j.bitcoin?.usd_24h_change);\nconst ethPrice=Number(j.ethereum?.usd), ethChg=Number(j.ethereum?.usd_24h_change);\nconst flags={\n  btc:{price:btcPrice, chg24:btcChg, cross_up:isFinite(btcPrice)&&btcPrice>=BTC_UP, cross_down:isFinite(btcPrice)&&btcPrice<=BTC_DOWN, big_move:isFinite(btcChg)&&Math.abs(btcChg)>=MOVE_ABS},\n  eth:{price:ethPrice, chg24:ethChg, cross_up:isFinite(ethPrice)&&ethPrice>=ETH_UP, cross_down:isFinite(ethPrice)&&ethPrice<=ETH_DOWN, big_move:isFinite(ethChg)&&Math.abs(ethChg)>=MOVE_ABS},\n  ts: now\n};\nreturn [{json: flags}];"
      },
      "typeVersion": 2
    },
    {
      "id": "c3a3e299-ebe7-499e-a0fc-9329690caadf",
      "name": "Any Alert?",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.btc.cross_up }}"
            },
            {
              "value1": "={{ $json.btc.cross_down }}"
            },
            {
              "value1": "={{ $json.btc.big_move }}"
            },
            {
              "value1": "={{ $json.eth.cross_up }}"
            },
            {
              "value1": "={{ $json.eth.cross_down }}"
            },
            {
              "value1": "={{ $json.eth.big_move }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "63226aa9-0d9d-499d-988b-6b10b877fe7d",
      "name": "Format Alert Email",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        0
      ],
      "parameters": {
        "jsCode": "const s=(n,d=2)=>isFinite(n)?Number(n).toFixed(d):'\u2014';\nconst sign=n=>isFinite(n)&&n>0?'+':'';\nconst j=$json; const lines=[\n  `BTC: $${s(j.btc.price,0)} (24h: ${sign(j.btc.chg24)}${s(j.btc.chg24)}%)`,\n  `ETH: $${s(j.eth.price,0)} (24h: ${sign(j.eth.chg24)}${s(j.eth.chg24)}%)`\n];\nreturn [{json:{\n  subject:`\u26a0\ufe0f Crypto Alert \u2014 ${new Date().toLocaleString('en-US',{timeZone:'Africa/Lagos'})}`,\n  html:`<p>${lines.join('<br>')}</p>`,\n  text: lines.join('\\n')\n}}];"
      },
      "typeVersion": 2
    },
    {
      "id": "98e5269e-9607-46ad-8dd1-b8c7c8c37a8f",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1040,
        96
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.html }}",
        "options": {
          "appendAttribution": true
        },
        "subject": "={{ $json.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "76dfd7da-7369-4a97-9d6b-72ed12df0b4c",
      "name": "Send an SMS/MMS/WhatsApp message",
      "type": "n8n-nodes-base.twilio",
      "position": [
        1040,
        -112
      ],
      "parameters": {
        "message": "={{ $('Format Alert Email').item.json.text }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "3e6cc369-0736-4414-919b-8907016e470e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -480
      ],
      "parameters": {
        "width": 912,
        "height": 720,
        "content": "## \u26a0\ufe0f Crypto Price Threshold Alerts (Email/SMS/Telegram)\n\n**What it does:**  \nSends an alert when **BTC/ETH** crosses your target prices or when **24h % change** moves beyond your set threshold.\n\n**Trigger:**  \nEvery **10\u201315 minutes** (adjust cron as you like).\n\n**Nodes:**  \nSchedule \u2192 **CoinGecko** (BTC, ETH) \u2192 **Code** (compare thresholds) \u2192 **IF** \u2192 Email / **Twilio** / **Telegram**\n\n**Typical Output:**  \n\u201c**BTC broke $110,000** (+2.1% 24h)\u201d\n\n**How to customize (quick):**  \n- **Targets:** `BTC_UP`, `BTC_DOWN`, `ETH_UP`, `ETH_DOWN`  \n- **24h movement threshold:** `MOVE_ABS` (e.g., 2.0 = \u00b12%)  \n- Swap or add channels: **Email**, **Twilio SMS**, **Telegram**, **Slack**\n\n**Pro tip:**  \nDebounce with a small memory/Sheet to prevent repeated alerts if price hovers around the threshold.\n\n**Author:** David Olusola  \n**Traning & 1:1 consulting:** [sales@daexai.com](mailto:sales@daexai.com)\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Any Alert?": {
      "main": [
        [
          {
            "node": "Format Alert Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Every 15 Minutes": {
      "main": [
        [
          {
            "node": "Get Crypto Prices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Crypto Prices": {
      "main": [
        [
          {
            "node": "Compute Threshold Flags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert Email": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send an SMS/MMS/WhatsApp message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compute Threshold Flags": {
      "main": [
        [
          {
            "node": "Any Alert?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}