Claude n8n flow - Reddit Grab

    Shared 2/19/2026

    1 views

    Visual Workflow

    JSON Code

    {
      "name": "r/FacebookAds Daily Insights Report",
      "nodes": [
        {
          "name": "Schedule Trigger",
          "type": "n8n-nodes-base.cron",
          "position": [
            100,
            300
          ],
          "parameters": {
            "cronExpression": "0 9 * * *"
          },
          "typeVersion": 1
        },
        {
          "name": "Fetch Reddit Posts",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            300,
            300
          ],
          "parameters": {
            "url": "https://www.reddit.com/r/FacebookAds/new.json?limit=25",
            "options": {
              "headers": {
                "User-Agent": "n8n-heave-workflow/1.0"
              }
            }
          },
          "typeVersion": 1
        },
        {
          "name": "Extract Posts",
          "type": "n8n-nodes-base.function",
          "position": [
            500,
            300
          ],
          "parameters": {
            "functionCode": "const children = items[0].json.data.children;\n\nconst posts = children.map(child => {\n  const post = child.data;\n  return {\n    json: {\n      id: post.id,\n      title: post.title,\n      selftext: post.selftext || '',\n      score: post.score,\n      num_comments: post.num_comments,\n      url: `https://www.reddit.com${post.permalink}`,\n      comments_url: `https://www.reddit.com${post.permalink}.json?limit=10`\n    }\n  };\n});\n\nreturn posts;"
          },
          "typeVersion": 1
        },
        {
          "name": "Fetch Comments Per Post",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            700,
            300
          ],
          "parameters": {
            "url": "={{$json[\"comments_url\"]}}",
            "options": {
              "headers": {
                "User-Agent": "n8n-heave-workflow/1.0"
              }
            }
          },
          "typeVersion": 1
        },
        {
          "name": "Extract Posts + Comments",
          "type": "n8n-nodes-base.function",
          "position": [
            900,
            300
          ],
          "parameters": {
            "functionCode": "const results = [];\n\nfor (const item of items) {\n  try {\n    const postData = item.json[0]?.data?.children?.[0]?.data || {};\n    const commentChildren = item.json[1]?.data?.children || [];\n\n    const comments = commentChildren\n      .filter(c => c.kind === 't1')\n      .map(c => c.data.body)\n      .filter(Boolean)\n      .slice(0, 10);\n\n    results.push({\n      json: {\n        title: postData.title || 'No title',\n        body: postData.selftext || '',\n        score: postData.score || 0,\n        num_comments: postData.num_comments || 0,\n        url: `https://www.reddit.com${postData.permalink || ''}`,\n        comments: comments\n      }\n    });\n  } catch (e) {\n    // skip malformed posts\n  }\n}\n\nreturn results;"
          },
          "typeVersion": 1
        },
        {
          "name": "Aggregate All Posts",
          "type": "n8n-nodes-base.function",
          "position": [
            1100,
            300
          ],
          "parameters": {
            "functionCode": "// Aggregate all posts into one item for the AI to process\nconst allPosts = items.map(item => {\n  const d = item.json;\n  return {\n    title: d.title,\n    body: d.body,\n    score: d.score,\n    num_comments: d.num_comments,\n    url: d.url,\n    comments: d.comments\n  };\n});\n\nreturn [{ json: { posts: allPosts } }];"
          },
          "typeVersion": 1
        },
        {
          "name": "Generate Insights via GPT-4",
          "type": "n8n-nodes-base.openAi",
          "position": [
            1300,
            300
          ],
          "parameters": {
            "model": "gpt-4",
            "options": {
              "maxTokens": 2000,
              "temperature": 0.5
            },
            "messages": {
              "values": [
                {
                  "role": "system",
                  "content": "You are an expert analyst in paid social media advertising, specifically Meta Ads (Facebook and Instagram). Your job is to analyse Reddit posts and comments from r/FacebookAds and produce a structured, actionable insights report."
                },
                {
                  "role": "user",
                  "content": "=Here is a batch of posts and comments from r/FacebookAds from the last 24 hours. Please analyse them and produce a structured insights report with the following sections:\n\n1. 🔥 TOP ISSUES & PROBLEMS - What are advertisers struggling with most?\n2. ❓ TOP QUESTIONS - What are people asking about most?\n3. 💡 SOLUTIONS & TIPS SHARED - What advice or fixes are being shared in comments?\n4. 📊 TRENDS & PATTERNS - Any notable themes, repeated topics, or emerging trends?\n5. 🚨 WATCH OUT - Any warnings, bugs, or platform changes being flagged?\n6. 🔗 NOTABLE POSTS - Link the 3 most interesting or high-engagement posts with a one-line summary.\n\nKeep the report concise but packed with insight. Use bullet points. Here is the data:\n\n{{JSON.stringify($json.posts)}}"
                }
              ]
            },
            "resource": "chat",
            "operation": "complete",
            "authentication": "apiKey"
          },
          "typeVersion": 1
        },
        {
          "name": "Format Slack Message",
          "type": "n8n-nodes-base.function",
          "position": [
            1500,
            300
          ],
          "parameters": {
            "functionCode": "const report = items[0].json.message.content;\nconst today = new Date().toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });\n\nreturn [{\n  json: {\n    slackMessage: `*📣 r/FacebookAds Daily Insights Report*\\n*${today}*\\n\\n${report}\\n\\n_Source: https://www.reddit.com/r/FacebookAds/new/_`\n  }\n}];"
          },
          "typeVersion": 1
        },
        {
          "name": "Send to Slack",
          "type": "n8n-nodes-base.slack",
          "position": [
            1700,
            300
          ],
          "parameters": {
            "text": "={{$json[\"slackMessage\"]}}",
            "channel": "@timi",
            "otherOptions": {
              "mrkdwn": true
            }
          },
          "typeVersion": 1
        }
      ],
      "connections": {
        "Extract Posts": {
          "main": [
            [
              {
                "node": "Fetch Comments Per Post",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Schedule Trigger": {
          "main": [
            [
              {
                "node": "Fetch Reddit Posts",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Fetch Reddit Posts": {
          "main": [
            [
              {
                "node": "Extract Posts",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Aggregate All Posts": {
          "main": [
            [
              {
                "node": "Generate Insights via GPT-4",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Format Slack Message": {
          "main": [
            [
              {
                "node": "Send to Slack",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Fetch Comments Per Post": {
          "main": [
            [
              {
                "node": "Extract Posts + Comments",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Extract Posts + Comments": {
          "main": [
            [
              {
                "node": "Aggregate All Posts",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Generate Insights via GPT-4": {
          "main": [
            [
              {
                "node": "Format Slack Message",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }