{
  "name": "Reddit Keyword Monitor and Alert",
  "nodes": [
    {
      "parameters": {
        "subreddit": "={{ $env.REDDIT_SUBREDDIT }}",
        "filters": {},
        "options": {}
      },
      "id": "rkm0001-0001-4000-8000-000000000001",
      "name": "Reddit New Posts Trigger",
      "type": "n8n-nodes-base.redditTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "jsCode": "const keywords = (process.env.MONITOR_KEYWORDS || 'ai,automation,n8n').split(',').map(k => k.trim().toLowerCase());\nconst post = $input.item.json;\nconst titleLower = (post.title || '').toLowerCase();\nconst bodyLower = (post.selftext || '').toLowerCase();\nconst matched = keywords.filter(kw => titleLower.includes(kw) || bodyLower.includes(kw));\nreturn [{ json: { ...post, matched_keywords: matched, has_match: matched.length > 0 } }];"
      },
      "id": "rkm0001-0002-4000-8000-000000000002",
      "name": "Check Keywords",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.has_match }}",
              "value2": true
            }
          ]
        }
      },
      "id": "rkm0001-0003-4000-8000-000000000003",
      "name": "Keyword Matched?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "url": "={{ $env.SLACK_WEBHOOK_URL }}",
        "method": "POST",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=:reddit: *New Reddit mention detected!*\n\n*Keywords matched:* {{ $json.matched_keywords.join(', ') }}\n*Post:* {{ $json.title }}\n*Subreddit:* r/{{ $json.subreddit }}\n*Author:* u/{{ $json.author }}\n*Score:* {{ $json.score }}\n*Link:* https://reddit.com{{ $json.permalink }}"
            }
          ]
        },
        "options": {}
      },
      "id": "rkm0001-0004-4000-8000-000000000004",
      "name": "Send Slack Alert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [900, 220]
    }
  ],
  "connections": {
    "Reddit New Posts Trigger": {
      "main": [[{ "node": "Check Keywords", "type": "main", "index": 0 }]]
    },
    "Check Keywords": {
      "main": [[{ "node": "Keyword Matched?", "type": "main", "index": 0 }]]
    },
    "Keyword Matched?": {
      "main": [
        [{ "node": "Send Slack Alert", "type": "main", "index": 0 }],
        []
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
