8
n8n 中文网amn8n.com

Reddit新闻自动化专业版 - 多平台摘要

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 25 个节点。主要使用 If, Set, Code, Slack, Discord 等节点。 使用Gemini为Telegram、Discord和Slack生成AI精选Reddit摘要

前置要求
  • Slack Bot Token 或 Webhook URL
  • Discord Bot Token 或 Webhook
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "MZnTCmdajWSdVOOj",
  "meta": {
    "instanceId": "e46a00fdf674c6a717d1781ab876c72daac39cdddf1349ff176b416ee5840ee5",
    "templateCredsSetupCompleted": true
  },
  "name": "Reddit 新闻自动化专业版 - 多平台摘要",
  "tags": [],
  "nodes": [
    {
      "id": "80444483-f96c-4e9b-a190-89220d18c280",
      "name": "📖 主要文档(从此开始)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -496
      ],
      "parameters": {
        "color": 4,
        "width": 530,
        "height": 1442,
        "content": "# 🔥 Reddit 新闻自动化专业版 - 多平台摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "a26acf04-a3b6-4ce8-b1f9-79bab59f7998",
      "name": "便签 - 触发器部分",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -496
      ],
      "parameters": {
        "color": 5,
        "width": 316,
        "height": 554,
        "content": "## 🎬 步骤 1:触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "0f1a3665-4e84-45bc-a354-377bfdcedb67",
      "name": "便签 - 配置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -576
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 617,
        "content": "## ⚙️ 步骤 2:配置"
      },
      "typeVersion": 1
    },
    {
      "id": "840d9ff1-ebe6-4583-863f-caa949e6fcfe",
      "name": "便签 - 数据处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        -448
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 464,
        "content": "## 🔄 步骤 3:数据处理"
      },
      "typeVersion": 1
    },
    {
      "id": "1c4e6f9a-db18-4473-8a2f-f950977f3731",
      "name": "便签 - 获取数据",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -432
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 441,
        "content": "## 📥 步骤 4:获取 Reddit 数据"
      },
      "typeVersion": 1
    },
    {
      "id": "66dc19c8-80eb-4a37-b5dc-752c756d1637",
      "name": "便签 - 解析帖子",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        -496
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 441,
        "content": "## 🔍 步骤 5:解析和清理"
      },
      "typeVersion": 1
    },
    {
      "id": "522b356f-35b6-4d30-953e-51f0c47ff539",
      "name": "便签 - 聚合",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        -512
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 441,
        "content": "## 📊 步骤 6:聚合和去重"
      },
      "typeVersion": 1
    },
    {
      "id": "4ce64fee-4588-4b13-8d6a-104c18811c3f",
      "name": "便签 - AI 筛选",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        -640
      ],
      "parameters": {
        "color": 5,
        "width": 358,
        "height": 546,
        "content": "## 🤖 步骤 7:AI 筛选"
      },
      "typeVersion": 1
    },
    {
      "id": "cee5bc74-c80e-455d-a69f-1f061fe4ad15",
      "name": "便签 - 格式化输出",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2672,
        -704
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 601,
        "content": "## 📝 步骤 8:格式化输出"
      },
      "typeVersion": 1
    },
    {
      "id": "27d43d74-19ab-4e1e-9161-fb6b5efdaf8a",
      "name": "便签 - 验证",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        320
      ],
      "parameters": {
        "color": 5,
        "width": 327,
        "height": 446,
        "content": "## ✅ 步骤 9:验证"
      },
      "typeVersion": 1
    },
    {
      "id": "401c2f37-1c0f-462f-87e3-e57652c346c0",
      "name": "便签 - 分发平台",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2688,
        -64
      ],
      "parameters": {
        "color": 5,
        "width": 420,
        "height": 650,
        "content": "## 📤 步骤 10:分发"
      },
      "typeVersion": 1
    },
    {
      "id": "132efcb7-a0c6-4bca-8420-891971640e7f",
      "name": "📅 计划触发器(每天上午 9 点)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        384,
        96
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "43f60c9c-e735-4e3c-907e-91cca5cd377f",
      "name": "⚙️ 配置",
      "type": "n8n-nodes-base.set",
      "position": [
        592,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "subreddits",
              "name": "subreddits",
              "type": "string",
              "value": "=AI_Agents,generativeAI,ArtificialInteligence,MachineLearning,OpenAI,ChatGPT"
            },
            {
              "id": "posts_per_subreddit",
              "name": "posts_per_subreddit",
              "type": "number",
              "value": 25
            },
            {
              "id": "time_filter",
              "name": "time_filter",
              "type": "string",
              "value": "day"
            },
            {
              "id": "total_posts_in_digest",
              "name": "total_posts_in_digest",
              "type": "number",
              "value": 10
            },
            {
              "id": "digest_title",
              "name": "digest_title",
              "type": "string",
              "value": "🤖 AI Daily Digest"
            },
            {
              "id": "focus_keywords",
              "name": "focus_keywords",
              "type": "string",
              "value": "AI agents, ChatGPT, LLM, machine learning, research, tool, breakthrough"
            },
            {
              "id": "exclude_keywords",
              "name": "exclude_keywords",
              "type": "string",
              "value": "crypto, NFT, political, spam"
            },
            {
              "id": "min_upvotes",
              "name": "min_upvotes",
              "type": "number",
              "value": 10
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ced0b421-1f5b-4b47-93f8-1e69bc13f7da",
      "name": "📋 拆分 Subreddit 列表",
      "type": "n8n-nodes-base.set",
      "position": [
        784,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "subreddit_array",
              "name": "subreddit_array",
              "type": "array",
              "value": "={{ $json.subreddits.split(',').map(s => s.trim()) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0efa91cf-0173-4d52-9e79-cd7fe40ae9a5",
      "name": "🔄 遍历 Subreddit",
      "type": "n8n-nodes-base.set",
      "position": [
        992,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "subreddit",
              "name": "subreddit",
              "type": "string",
              "value": "={{ $json.subreddit_array[$itemIndex] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "75139925-31fb-4999-8ae3-da18c84fea16",
      "name": "🌐 获取 Reddit 帖子(JSON API)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1232,
        96
      ],
      "parameters": {
        "url": "=https://www.reddit.com/r/{{ $json.subreddit }}/top.json?t={{ $('⚙️ Configuration').first().json.time_filter }}&limit={{ $('⚙️ Configuration').first().json.posts_per_subreddit }}",
        "options": {
          "timeout": 30000,
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "n8n-reddit-automation/1.0"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "LDYdFaVICj6n2wNn",
          "name": "openrouter nano ban"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "351cd99a-2e3a-4be1-92f1-c3a782fd0a2b",
      "name": "🔍 解析和清理帖子",
      "type": "n8n-nodes-base.code",
      "position": [
        1424,
        96
      ],
      "parameters": {
        "jsCode": "// Extract and clean Reddit posts from JSON response\nconst data = $input.first().json.data;\nconst configData = $('⚙️ Configuration').first().json;\nconst minUpvotes = configData.min_upvotes || 0;\nconst currentSubreddit = $json.subreddit;\n\nif (!data || !data.children) {\n  return [{ json: { posts: [], error: 'No data found' } }];\n}\n\nconst posts = [];\n\nfor (const child of data.children) {\n  const post = child.data;\n  \n  // Skip if below minimum upvotes\n  if (post.ups < minUpvotes) continue;\n  \n  // Skip stickied posts (usually subreddit rules/announcements)\n  if (post.stickied) continue;\n  \n  // Skip removed/deleted posts\n  if (post.removed_by_category || post.selftext === '[removed]' || post.selftext === '[deleted]') continue;\n  \n  // Build clean post object\n  const cleanPost = {\n    id: post.id,\n    subreddit: currentSubreddit,\n    title: post.title.replace(/[\\r\\n]+/g, ' ').trim(),\n    url: post.url.startsWith('http') ? post.url : `https://www.reddit.com${post.permalink}`,\n    permalink: `https://www.reddit.com${post.permalink}`,\n    author: post.author,\n    upvotes: post.ups,\n    num_comments: post.num_comments,\n    created_utc: post.created_utc,\n    created_date: new Date(post.created_utc * 1000).toISOString(),\n    selftext: post.selftext ? post.selftext.substring(0, 500) : '',\n    is_self: post.is_self,\n    domain: post.domain,\n    score: post.score,\n    flair_text: post.link_flair_text || ''\n  };\n  \n  posts.push(cleanPost);\n}\n\n// Sort by score (upvotes)\nposts.sort((a, b) => b.score - a.score);\n\nreturn [{ json: { posts, subreddit: currentSubreddit, total_posts: posts.length } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "c2733e06-c5f5-48e0-8135-656dd108423b",
      "name": "📊 聚合和去重",
      "type": "n8n-nodes-base.code",
      "position": [
        1616,
        96
      ],
      "parameters": {
        "jsCode": "// Aggregate posts from all subreddits and apply smart filtering\nconst allItems = $input.all();\nconst configData = $('⚙️ Configuration').first().json;\n\n// Collect all posts from all subreddits\nconst allPosts = [];\nfor (const item of allItems) {\n  if (item.json.posts && Array.isArray(item.json.posts)) {\n    allPosts.push(...item.json.posts);\n  }\n}\n\n// Deduplicate by post ID\nconst uniquePosts = [];\nconst seenIds = new Set();\n\nfor (const post of allPosts) {\n  if (!seenIds.has(post.id)) {\n    seenIds.add(post.id);\n    uniquePosts.push(post);\n  }\n}\n\n// Apply keyword filtering if configured\nconst focusKeywords = configData.focus_keywords ? \n  configData.focus_keywords.toLowerCase().split(',').map(k => k.trim()) : [];\nconst excludeKeywords = configData.exclude_keywords ? \n  configData.exclude_keywords.toLowerCase().split(',').map(k => k.trim()) : [];\n\nconst filteredPosts = uniquePosts.filter(post => {\n  const searchText = `${post.title} ${post.selftext} ${post.flair_text}`.toLowerCase();\n  \n  // Check exclude keywords first\n  if (excludeKeywords.length > 0) {\n    for (const keyword of excludeKeywords) {\n      if (searchText.includes(keyword)) {\n        return false; // Exclude this post\n      }\n    }\n  }\n  \n  // If focus keywords are set, post must contain at least one\n  if (focusKeywords.length > 0) {\n    let hasKeyword = false;\n    for (const keyword of focusKeywords) {\n      if (searchText.includes(keyword)) {\n        hasKeyword = true;\n        break;\n      }\n    }\n    return hasKeyword;\n  }\n  \n  return true; // No filters or passed all filters\n});\n\n// Sort by score\nfilteredPosts.sort((a, b) => b.score - a.score);\n\nreturn [{ \n  json: { \n    all_posts: filteredPosts,\n    total_subreddits: allItems.length,\n    total_posts_fetched: allPosts.length,\n    total_unique_posts: uniquePosts.length,\n    total_filtered_posts: filteredPosts.length,\n    config: configData\n  } \n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7d167036-16e2-48cf-ace9-7b63b40dc69d",
      "name": "🤖 AI 内容筛选器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1808,
        96
      ],
      "parameters": {
        "text": "=You are an expert content curator for Reddit news digests. Your job is to analyze, rank, and format Reddit posts into a high-quality digest.\n\n## Context\n- Digest Title: {{ $json.config.digest_title }}\n- Target Audience: Tech-savvy users interested in {{ $json.config.focus_keywords }}\n- Total Posts Available: {{ $json.total_filtered_posts }}\n- Posts Needed: {{ $json.config.total_posts_in_digest }}\n\n## Your Task\n1. Review all provided Reddit posts\n2. Rank them by:\n   - Relevance to focus keywords: {{ $json.config.focus_keywords }}\n   - Quality and credibility of content\n   - Engagement (upvotes, comments)\n   - Uniqueness and value\n   - Recency and timeliness\n\n3. Select the TOP {{ $json.config.total_posts_in_digest }} most valuable posts\n\n4. Format them into a beautiful, scannable digest with this structure:\n\n```\n{{ $json.config.digest_title }}\n📅 {{ $now.format('MMMM DD, YYYY') }}\n━━━━━━━━━━━━━━━━━━━━\n\n[For each post, use this format:]\n\n1️⃣ **[Post Title]**\n   📍 r/[subreddit] • 👍 [upvotes] • 💬 [comments]\n   \n   [Write 1-2 sentences explaining why this post is valuable and what the key insight is]\n   \n   🔗 [Reddit URL]\n\n2️⃣ **[Next Post Title]**\n   ...\n\n━━━━━━━━━━━━━━━━━━━━\n💡 Curated by AI • {{ $json.total_filtered_posts }} posts analyzed\n```\n\n## Guidelines\n- Be concise but informative\n- Use emojis sparingly for visual hierarchy\n- Focus on WHY each post matters\n- Avoid jargon; explain technical terms\n- Keep summaries actionable\n- Number posts 1️⃣ through 🔟\n\n## Reddit Posts Data\n{{ JSON.stringify($json.all_posts, null, 2) }}\n\n## Output\nProvide ONLY the formatted digest text, ready to send. No meta-commentary.",
        "options": {
          "systemMessage": "You are a professional content curator. You create concise, valuable, and engaging content digests. You understand what makes content worth reading and can identify signal from noise."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "5610b7d3-4489-4314-8d57-40ac7a907c85",
      "name": "Google Gemini Flash 2.0",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1808,
        304
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "0e8207b0-4330-4e03-a155-fea83a88e8cd",
      "name": "📝 多平台格式化",
      "type": "n8n-nodes-base.code",
      "position": [
        2064,
        96
      ],
      "parameters": {
        "jsCode": "// Extract formatted output from AI response\nconst aiResponse = $input.first().json;\n\n// The AI agent returns output in different formats depending on the response\nlet formattedOutput = '';\n\nif (aiResponse.output) {\n  formattedOutput = aiResponse.output;\n} else if (aiResponse.text) {\n  formattedOutput = aiResponse.text;\n} else if (typeof aiResponse === 'string') {\n  formattedOutput = aiResponse;\n} else {\n  // Fallback: convert entire response to string\n  formattedOutput = JSON.stringify(aiResponse, null, 2);\n}\n\n// Clean up any extra whitespace\nformattedOutput = formattedOutput.trim();\n\nreturn [{ \n  json: { \n    formatted_output: formattedOutput,\n    timestamp: new Date().toISOString(),\n    digest_title: $('⚙️ Configuration').first().json.digest_title\n  } \n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fd16865d-a1f5-4085-89c8-e1193531bfcf",
      "name": "✅ 检查 AI 输出",
      "type": "n8n-nodes-base.if",
      "position": [
        2208,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "check-output",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.formatted_output }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ff981252-16c1-4307-810d-048106cb751e",
      "name": "📱 发送到 Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2464,
        -96
      ],
      "webhookId": "503f1790-45aa-4f10-9565-63e0025a4ca7",
      "parameters": {
        "text": "={{ $json.formatted_output }}",
        "chatId": "={{ $('⚙️ Configuration').first().json.telegram_chat_id || 'YOUR_CHAT_ID' }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5cc13e05-a01b-4bb5-b0d1-ed8e935c59f4",
      "name": "💬 发送到 Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        2464,
        96
      ],
      "webhookId": "f2cac624-a133-4201-a7eb-39328def4185",
      "parameters": {
        "content": "={{ $json.formatted_output }}",
        "options": {},
        "authentication": "webhook"
      },
      "typeVersion": 2
    },
    {
      "id": "20df81d2-629c-46ce-b367-b1a21d32fc98",
      "name": "💼 发送到 Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        2480,
        320
      ],
      "webhookId": "088380b0-220c-4bfc-9287-b6ab72b62840",
      "parameters": {
        "text": "={{ $json.formatted_output }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_CHANNEL_ID"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5e18ee82-46de-49aa-9cdf-88614eb2d4bc",
  "connections": {
    "✅ Check AI Output": {
      "main": [
        [
          {
            "node": "📱 Send to Telegram",
            "type": "main",
            "index": 0
          },
          {
            "node": "💬 Send to Discord",
            "type": "main",
            "index": 0
          },
          {
            "node": "💼 Send to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "⚙️ Configuration": {
      "main": [
        [
          {
            "node": "📋 Split Subreddit List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Flash 2.0": {
      "ai_languageModel": [
        [
          {
            "node": "🤖 AI Content Curator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "🤖 AI Content Curator": {
      "main": [
        [
          {
            "node": "📝 Format for Multiple Platforms",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔍 Parse & Clean Posts": {
      "main": [
        [
          {
            "node": "📊 Aggregate & Deduplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📋 Split Subreddit List": {
      "main": [
        [
          {
            "node": "🔄 Loop Through Subreddits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📊 Aggregate & Deduplicate": {
      "main": [
        [
          {
            "node": "🤖 AI Content Curator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔄 Loop Through Subreddits": {
      "main": [
        [
          {
            "node": "🌐 Fetch Reddit Posts (JSON API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🌐 Fetch Reddit Posts (JSON API)": {
      "main": [
        [
          {
            "node": "🔍 Parse & Clean Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📅 Schedule Trigger (Daily 9 AM)": {
      "main": [
        [
          {
            "node": "⚙️ Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📝 Format for Multiple Platforms": {
      "main": [
        [
          {
            "node": "✅ Check AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 市场调研, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量25
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流