{
  "id": "Qs7SzwsfqN05P3H2",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Reddit Crypto Intelligence & Market Spike Detector",
  "tags": [],
  "nodes": [
    {
      "id": "de966d28-3914-4942-889c-355dbd984451",
      "name": "Fetch Reddit Posts",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        256,
        0
      ],
      "parameters": {
        "url": "https://www.reddit.com/r/CryptoCurrency/new/.rss",
        "options": {},
        "responseFormat": "string"
      },
      "typeVersion": 1
    },
    {
      "id": "f73f317a-d1ef-425f-bd21-d99e57813ff0",
      "name": "Extract Coin Mentions",
      "type": "n8n-nodes-base.code",
      "position": [
        528,
        0
      ],
      "parameters": {
        "jsCode": "// Handle both string and object responses safely\nlet xml = items[0].json;\n\nif (typeof xml === 'object') {\n  // Sometimes n8n wraps RSS inside a \"body\" or returns it as JSON\n  xml = xml.body || JSON.stringify(xml);\n}\n\n// Ensure xml is a string\nif (typeof xml !== 'string') {\n  xml = String(xml);\n}\n\n// Extract <title> tags (works for Atom feeds too)\nconst titles = [];\nconst regex = /<title>(?:<!\\[CDATA\\[)?(.*?)(?:\\]\\]>)?<\\/title>/gms;\nlet match;\nwhile ((match = regex.exec(xml)) !== null) {\n  titles.push(match[1].toLowerCase());\n}\n\n// Find coin mentions\nconst coinsMentioned = new Set();\n\nfor (const title of titles) {\n  if (title.includes('btc') || title.includes('bitcoin')) coinsMentioned.add('bitcoin');\n  if (title.includes('eth') || title.includes('ethereum')) coinsMentioned.add('ethereum');\n  if (title.includes('sol') || title.includes('solana')) coinsMentioned.add('solana');\n  if (title.includes('doge') || title.includes('dogecoin')) coinsMentioned.add('dogecoin');\n  if (title.includes('xrp')) coinsMentioned.add('ripple');\n  if (title.includes('ada') || title.includes('cardano')) coinsMentioned.add('cardano');\n}\n\n// Return results\nreturn Array.from(coinsMentioned).map(coin => ({ json: { coin } }));"
      },
      "typeVersion": 1
    },
    {
      "id": "af8387f2-a014-4398-be40-ad0d4c1168d3",
      "name": "Fetch Coin Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        0
      ],
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=1",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "1e21559f-f057-4ec5-9696-c451ff3a3929",
      "name": "Detect Price Spike",
      "type": "n8n-nodes-base.code",
      "position": [
        1072,
        0
      ],
      "parameters": {
        "jsCode": "// Get input data safely\nconst itemsIn = items.length > 0 ? items : [];\nif (itemsIn.length === 0) {\n  return [{ json: { message: 'No price data received' } }];\n}\n\n// Extract prices safely\nconst priceData = itemsIn.map(i => i.json).filter(d => d && d.current_price !== undefined);\n\n// Early exit if missing data\nif (priceData.length === 0) {\n  return [{ json: { message: 'No valid price data found' } }];\n}\n\n// Detect spikes: > 10% up or down in 24h\nconst threshold = 10; // percent\nconst spikes = [];\n\nfor (const token of priceData) {\n  const change = token.price_change_percentage_24h;\n  if (typeof change === 'number' && Math.abs(change) >= threshold) {\n    spikes.push({\n      id: token.id,\n      symbol: token.symbol,\n      name: token.name,\n      current_price: token.current_price,\n      change_24h: change,\n      direction: change > 0 ? 'up' : 'down',\n      last_updated: token.last_updated\n    });\n  }\n}\n\n// Return n8n-compatible output\nif (spikes.length === 0) {\n  return [{ json: { message: 'No major price spikes detected' } }];\n}\n\nreturn spikes.map(spike => ({ json: spike }));"
      },
      "typeVersion": 1
    },
    {
      "id": "601b2165-dec2-4807-ad72-5343eecf2b23",
      "name": "Compose Discord Message",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        0
      ],
      "parameters": {
        "jsCode": "const data = $json;\n\n// If no spike data, send a generic message\nif (!data.symbol || !data.name || data.change_24h === undefined) {\n  return {\n    json: {\n      content: `No price spikes detected in the latest check.`\n    }\n  };\n}\n\nconst directionEmoji = data.direction === 'up' ? '\ud83d\ude80' : '\ud83d\udcc9';\nconst changeText = data.change_24h.toFixed(2);\nconst msg = `${directionEmoji} **${data.name} (${data.symbol.toUpperCase()})** moved *${changeText}%* ${data.direction} in the last 24h!\\n\ud83d\udcb0 Price: $${data.current_price}\\n\ud83d\udd52 Updated: ${data.last_updated}`;\n\nreturn {\n  json: {\n    content: msg\n  }\n};"
      },
      "typeVersion": 1
    },
    {
      "id": "dcba08bf-62c3-4cff-a327-d0fc45d14718",
      "name": "Send a message",
      "type": "n8n-nodes-base.discord",
      "position": [
        1568,
        0
      ],
      "parameters": {
        "content": "={{ $json.content }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1280652666577354803",
          "cachedResultUrl": "https://discord.com/channels/1280652666577354803",
          "cachedResultName": "Renz's server"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1280652667408089210",
          "cachedResultUrl": "https://discord.com/channels/1280652666577354803/1280652667408089210",
          "cachedResultName": "general"
        }
      },
      "credentials": {
        "discordBotApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6c67e9ae-1b14-422d-aaf2-df6b4a4d0aaf",
      "name": "Hourly",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6f44e950-9086-4aa6-89e3-39ea0ddc0998",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -240
      ],
      "parameters": {
        "width": 224,
        "height": 400,
        "content": "This node schedules the workflow to run automatically every hour.\nIt ensures consistent monitoring of Reddit activity without manual execution.\nYou can adjust the interval as needed (e.g., every 15 minutes or 2 hours)."
      },
      "typeVersion": 1
    },
    {
      "id": "bd5d8e35-74de-4cc4-ad71-e0b152ff236b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -240
      ],
      "parameters": {
        "color": 2,
        "width": 272,
        "height": 400,
        "content": "This node retrieves the latest posts from the r/CryptoCurrency subreddit using Reddit\u2019s public RSS feed.\nThe feed provides a lightweight and free way to monitor new crypto discussions in real time.\nEach post includes a title, link, author, and timestamp.\nThese are then parsed to detect potential mentions of new tokens or trending coins."
      },
      "typeVersion": 1
    },
    {
      "id": "a99448b3-dcde-459f-abba-ec9c675d49b9",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 272,
        "height": 400,
        "content": "This node retrieves live price data and 24-hour percentage changes for the detected coin symbols from the CoinGecko public API.\nCoinGecko is completely free to use with a rate limit of 10\u201330 calls per minute (no API key required).\nThis step connects Reddit sentiment to real-time market data.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8294e1e8-bb28-4bcd-8088-19e322765e16",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -240
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 400,
        "content": "This code node extracts coin tickers or symbols (e.g., $BTC, $ETH, $SOL, $MOONX) from the Reddit post titles.\nIt uses a simple regex (\\$[A-Za-z0-9]{2,10}) to detect these mentions.\nThe results are cleaned and standardized to lowercase for easier processing.\nIf no matches are found, the node returns a \u201cNo coin mentions detected\u201d message.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c00ae4b4-706b-4a1a-ac4f-feb932fb80ff",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 400,
        "content": "This code node detects significant market movements (default \u00b15% in 24h).\nIf any coin mentioned on Reddit has a large movement, it\u2019s flagged as a potential market signal.\nThis node filters out noise and highlights only meaningful spikes."
      },
      "typeVersion": 1
    },
    {
      "id": "69608355-b258-45ee-b304-c336817cd929",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        -240
      ],
      "parameters": {
        "color": 6,
        "height": 400,
        "content": "This node builds a clear, well-formatted alert message for Discord.\nIf price spikes were detected, it lists each coin with price, change %, and timestamp.\nIf no spikes were found, it sends a neutral \u201cno changes\u201d message instead."
      },
      "typeVersion": 1
    },
    {
      "id": "9d4903f1-7a90-4307-bf97-f9c56b1a37ec",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -240
      ],
      "parameters": {
        "color": 7,
        "height": 400,
        "content": "This node posts the composed message into your Discord channel via Webhook.\nYou can set up the Webhook inside your Discord server (Settings \u2192 Integrations \u2192 Webhooks).\nThis creates a simple and real-time alert delivery system."
      },
      "typeVersion": 1
    },
    {
      "id": "34f756c9-e83a-4cf8-b171-3abaf3358965",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        -208
      ],
      "parameters": {
        "width": 672,
        "height": 368,
        "content": "This n8n automation continuously monitors the r/CryptoCurrency subreddit for new coin mentions, correlates them with live CoinGecko market data, and detects significant market movements.\n\nWhen price spikes are identified, it sends real-time Discord alerts summarizing affected tokens, price, and percentage change.\n\nBy blending social sentiment signals with market analytics, this workflow acts as an early-warning system for trending tokens and volatility events \u2014 all using free, open APIs.\n\n\ud83e\udde9 n8n instance: Self-hosted or Cloud\n\ud83d\udcac Discord Webhook URL: Create via Discord \u2192 Server Settings \u2192 Integrations \u2192 Webhooks\n\ud83c\udf10 Reddit RSS Feed (Free) URL: https://www.reddit.com/r/CryptoCurrency/new/.rss\n\ud83d\udcca CoinGecko API (Free): No API key required\n\u23f0 Recommended schedule: Every hour or every 30 minutes\n\n## AFK Crypto Website: afkcrypto.com"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "589c20d8-9d91-4fb5-bd33-065d2b1be371",
  "connections": {
    "Hourly": {
      "main": [
        [
          {
            "node": "Fetch Reddit Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Coin Data": {
      "main": [
        [
          {
            "node": "Detect Price Spike",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Price Spike": {
      "main": [
        [
          {
            "node": "Compose Discord Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Reddit Posts": {
      "main": [
        [
          {
            "node": "Extract Coin Mentions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Coin Mentions": {
      "main": [
        [
          {
            "node": "Fetch Coin Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Discord Message": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}