{
  "name": "Reddit Search Scraper (RedditScrapers.com)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "id": "3df504a4-5280-4b17-92ce-79915d2f4738",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        -1136,
        -80
      ],
      "notes": "Runs every 6 hours. Change the interval to suit your needs, or swap this for a Webhook or Manual trigger."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "param-001",
              "name": "searchQuery",
              "value": "YOUR_SEARCH_QUERY",
              "type": "string"
            },
            {
              "id": "param-002",
              "name": "maxItems",
              "value": 25,
              "type": "number"
            },
            {
              "id": "param-003",
              "name": "sort",
              "value": "top",
              "type": "string"
            },
            {
              "id": "param-004",
              "name": "timeFilter",
              "value": "week",
              "type": "string"
            },
            {
              "id": "param-005",
              "name": "subreddit",
              "value": "",
              "type": "string"
            },
            {
              "id": "param-006",
              "name": "apifyToken",
              "value": "YOUR_APIFY_TOKEN",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "d9354f4e-ee55-49ae-ad1c-0f65da4e06d5",
      "name": "Set Search Params",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        -928,
        -80
      ],
      "notes": "✏️ Edit these values:\n- searchQuery: keyword to search Reddit for\n- maxItems: number of posts to return (max 100)\n- sort: relevance | top | new | comments\n- timeFilter: hour | day | week | month | year | all\n- subreddit: leave empty to search all of Reddit\n- apifyToken: your Apify API token from https://console.apify.com/account/integrations"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/2aTxJQei6EYjQsD9A/runs",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.apifyToken }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "searchQueries",
              "value": "={{ [$json.searchQuery] }}"
            },
            {
              "name": "maxItems",
              "value": "={{ $json.maxItems }}"
            },
            {
              "name": "sort",
              "value": "={{ $json.sort }}"
            },
            {
              "name": "time",
              "value": "={{ $json.timeFilter }}"
            },
            {
              "name": "subreddit",
              "value": "={{ $json.subreddit }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "db7906c8-57f9-4ab5-9af0-bb4e84cb8445",
      "name": "Start Reddit Scraper",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -704,
        -80
      ],
      "notes": "Calls the Reddit Posts Search Scraper on Apify (actor: 2aTxJQei6EYjQsD9A).\nGet the scraper at: https://console.apify.com/actors/2aTxJQei6EYjQsD9A?fpr=redditscrapers\nPowered by RedditScrapers.com"
    },
    {
      "parameters": {
        "url": "=https://api.apify.com/v2/acts/2aTxJQei6EYjQsD9A/runs/last/dataset/items?token={{ $('Set Search Params').item.json.apifyToken }}&format=json&clean=true&limit={{ $('Set Search Params').item.json.maxItems }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "ecac6f6a-b3d1-4ad9-89fe-6b18a2fcbc1c",
      "name": "Fetch Results",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -256,
        -80
      ],
      "notes": "Fetches the scraped Reddit posts from the last run's dataset.\nReturns an array of posts with: title, author, subreddit, score, url, body, num_comments, created_utc, upvote_ratio, awards, image_url, comments[]"
    },
    {
      "parameters": {
        "jsCode": "// Filter & enrich Reddit posts\n// Powered by RedditScrapers.com\n\nconst items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n  const post = item.json;\n\n  // Skip low-quality posts\n  if (!post.title) continue;\n  const score = post.score || 0;\n\n  // Classify post quality\n  let quality = 'low';\n  if (score >= 500) quality = 'viral';\n  else if (score >= 100) quality = 'trending';\n  else if (score >= 10) quality = 'active';\n\n  // Build enriched output\n  results.push({\n    json: {\n      title:          post.title,\n      author:         post.author || 'unknown',\n      subreddit:      post.subreddit || '',\n      score:          score,\n      upvote_ratio:   post.upvote_ratio || null,\n      num_comments:   post.num_comments || 0,\n      url:            post.url || '',\n      permalink:      post.permalink\n                        ? 'https://reddit.com' + post.permalink\n                        : '',\n      body:           post.body || '',\n      created_utc:    post.created_utc || null,\n      created_date:   post.created_utc\n                        ? new Date(post.created_utc * 1000).toISOString()\n                        : null,\n      awards:         post.awards || 0,\n      quality_tag:    quality,\n      top_comment:    post.comments && post.comments.length > 0\n                        ? post.comments[0].body || ''\n                        : '',\n      scraped_by:     'RedditScrapers.com',\n      scraped_at:     new Date().toISOString()\n    }\n  });\n}\n\n// Sort by score descending\nresults.sort((a, b) => b.json.score - a.json.score);\n\nreturn results;\n"
      },
      "id": "6444d291-910e-4b48-9d13-d486d18dc24c",
      "name": "Filter & Enrich Posts",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -32,
        -80
      ],
      "notes": "Filters, enriches and sorts the scraped posts.\n- Adds quality_tag: viral (≥500) | trending (≥100) | active (≥10) | low\n- Extracts top comment\n- Converts Unix timestamp to ISO date\n- Sorts by score descending"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "cond-viral",
              "leftValue": "={{ $json.quality_tag }}",
              "rightValue": "viral",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "7dffea21-bd4d-4051-a7f0-c4fc6a3fdb60",
      "name": "Is Viral?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        192,
        -80
      ],
      "notes": "Routes viral posts (score ≥ 500) to an immediate Slack alert.\nAll posts still continue to the Google Sheets node."
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit#gid=0"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "title",
              "displayName": "title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "author",
              "displayName": "author",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "subreddit",
              "displayName": "subreddit",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "score",
              "displayName": "score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "upvote_ratio",
              "displayName": "upvote_ratio",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "num_comments",
              "displayName": "num_comments",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "url",
              "displayName": "url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "permalink",
              "displayName": "permalink",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "created_utc",
              "displayName": "created_utc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "created_date",
              "displayName": "created_date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "awards",
              "displayName": "awards",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "quality_tag",
              "displayName": "quality_tag",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "top_comment",
              "displayName": "top_comment",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "scraped_by",
              "displayName": "scraped_by",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "scraped_at",
              "displayName": "scraped_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "ce65bad2-4303-48f1-a548-a8239ae68113",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        400,
        -192
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account"
        }
      },
      "notes": "✏️ Replace YOUR_GOOGLE_SHEET_ID with your actual Google Sheet ID.\nAll enriched posts are appended with title, score, author, subreddit, url, quality_tag, and scraped_at."
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "YOUR_SLACK_CHANNEL_ID",
          "mode": "list",
          "cachedResultName": "n8n-automation"
        },
        "text": "=🔥 *Viral Reddit Post Detected!*\n\n*{{ $json.title }}*\n📊 Score: {{ $json.score }} | 💬 {{ $json.num_comments }} comments\n🏠 {{ $json.subreddit }} | 👤 u/{{ $json.author }}\n\n{{ $json.permalink }}\n\n_Scraped by RedditScrapers.com_",
        "otherOptions": {
          "mrkdwn": true
        }
      },
      "id": "f4f3e4af-74f9-4dbd-9ad4-f3761a65c767",
      "name": "Slack Alert (Viral)",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        400,
        16
      ],
      "webhookId": "YOUR_SLACK_WEBHOOK_ID",
      "credentials": {
        "slackOAuth2Api": {
          "id": "YOUR_SLACK_CREDENTIAL_ID",
          "name": "Slack account"
        }
      },
      "notes": "✏️ Replace YOUR_SLACK_CHANNEL_ID with your Slack channel.\nSends an alert only for posts with score ≥ 500."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "YOUR_WEBHOOK_URL",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"source\": \"RedditScrapers.com\",\n  \"query\": \"{{ $('Set Search Params').item.json.searchQuery }}\",\n  \"total_posts\": {{ $('Filter & Enrich Posts').all().length }},\n  \"top_post\": {\n    \"title\": \"{{ $json.title }}\",\n    \"score\": {{ $json.score }},\n    \"url\": \"{{ $json.permalink }}\"\n  },\n  \"scraped_at\": \"{{ $json.scraped_at }}\"\n}",
        "options": {}
      },
      "id": "bd78d7c9-73a9-4c68-a225-db83f793c4cd",
      "name": "Webhook Output",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        400,
        208
      ],
      "notes": "✏️ Replace YOUR_WEBHOOK_URL with any endpoint (e.g. your app, Make.com, Zapier, Airtable webhook).\nPOSTs a summary payload including the top post and total results count."
    },
    {
      "parameters": {
        "amount": 60
      },
      "id": "71809e53-e164-4173-9fdd-2cef67f9f83a",
      "name": "Wait 60s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -480,
        -80
      ],
      "webhookId": "WAIT_WEBHOOK_ID",
      "notes": "Wait for the Apify actor run to complete before fetching results. Increase this if scraping large datasets."
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set Search Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Search Params": {
      "main": [
        [
          {
            "node": "Start Reddit Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Reddit Scraper": {
      "main": [
        [
          {
            "node": "Wait 60s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Results": {
      "main": [
        [
          {
            "node": "Filter & Enrich Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter & Enrich Posts": {
      "main": [
        [
          {
            "node": "Is Viral?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Viral?": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack Alert (Viral)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Webhook Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60s": {
      "main": [
        [
          {
            "node": "Fetch Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "PUBLIC_TEMPLATE",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "PUBLIC_TEMPLATE_INSTANCE"
  },
  "id": "ZQzUJkIwerSGWo8V",
  "tags": [
    {
      "name": "scraping",
      "id": "1KKDDBtBgLYowiYl",
      "updatedAt": "2026-03-15T19:56:09.398Z",
      "createdAt": "2026-03-15T19:56:09.398Z"
    },
    {
      "name": "reddit",
      "id": "CPGuX86fKz5FcUzm",
      "updatedAt": "2026-03-15T19:56:09.336Z",
      "createdAt": "2026-03-15T19:56:09.336Z"
    },
    {
      "name": "apify",
      "id": "ym7bkMzUwOb8ZEEi",
      "updatedAt": "2026-03-15T19:56:09.364Z",
      "createdAt": "2026-03-15T19:56:09.364Z"
    }
  ]
}