AutomationFlowsAI & RAG › Reddit Insights N8n

Reddit Insights N8n

Reddit-Insights-N8N. Uses @brightdata/n8n-nodes-brightdata, agent, lmChatGoogleGemini, rssFeedRead. Scheduled trigger; 29 nodes.

Cron / scheduled trigger★★★★☆ complexityAI-powered29 nodes@Brightdata/N8N Nodes BrightdataAgentGoogle Gemini ChatRSS Feed ReadNotionHTTP Request
AI & RAG Trigger: Cron / scheduled Nodes: 29 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "parameters": {
        "options": {
          "reset": true
        }
      },
      "id": "b77a08a2-5574-4b67-8fea-ab68068cf5eb",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1488,
        368
      ],
      "typeVersion": 3
    },
    {
      "parameters": {},
      "id": "a8c961a0-850b-4f45-8828-0a640d35817a",
      "name": "Check Snapshot Again for Success",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2304,
        464
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "operation": "monitorProgressSnapshot",
        "snapshot_id": "={{ $json.snapshot_id }}",
        "requestOptions": {}
      },
      "id": "196598e6-b488-4cc8-88e5-b75088bb2287",
      "name": "Check the status of a batch extraction",
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "position": [
        1712,
        368
      ],
      "typeVersion": 1,
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f5deab49-ea1c-456b-b61a-5458adf991a5",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "ready"
            }
          ]
        },
        "options": {}
      },
      "id": "b16319ef-2ff0-49f0-821d-541ee02dd71a",
      "name": "Check if Batch Ready",
      "type": "n8n-nodes-base.if",
      "position": [
        1872,
        256
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "operation": "downloadSnapshot",
        "snapshot_id": "={{ $json.snapshot_id }}",
        "requestOptions": {}
      },
      "id": "45cf4c7c-7135-4cea-a985-591dde2ce7db",
      "name": "Download the snapshot content",
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "position": [
        2112,
        256
      ],
      "typeVersion": 1,
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e30d65f3-a6be-4df2-8672-2f69633f9296",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "cc932518-35b3-42cc-9ed7-76b695c5607a",
              "name": "description",
              "type": "string",
              "value": "={{ $json.description }}"
            },
            {
              "id": "3cd26612-27f6-4d31-bfe0-7075d2c05a44",
              "name": "comments",
              "type": "array",
              "value": "={{ $json.comments }}"
            },
            {
              "id": "54b22b70-0c4c-4e68-975b-77fbf2112ede",
              "name": "post_id",
              "type": "string",
              "value": "={{ $json.post_id }}"
            },
            {
              "id": "189999eb-6f59-4810-be8f-dfd1f7f01ef5",
              "name": "url",
              "type": "string",
              "value": "={{ $json.url }}"
            },
            {
              "id": "332a53a2-4182-4490-adc3-1a87426c0ba1",
              "name": "num_upvotes",
              "type": "number",
              "value": "={{ $json.num_upvotes }}"
            },
            {
              "id": "2754e3a3-ee58-4c75-ae8c-296f4c1249a0",
              "name": "num_comments",
              "type": "number",
              "value": "={{ $json.num_comments }}"
            }
          ]
        },
        "options": {}
      },
      "id": "bdf36077-ca72-4116-b85b-9dcd8fe186eb",
      "name": "Extract Essential Data",
      "type": "n8n-nodes-base.set",
      "position": [
        2592,
        352
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "00bbe5d7-c761-422c-a542-b32c0f59fd47",
              "name": "postdata",
              "type": "string",
              "value": "=Title: {{ $json.title }}\nDescription: {{ $json.description }}\nURL: {{ $json.url }}\nUpvotes: {{ $json.num_upvotes }}\nComment Count: {{ $json.num_comments }}\nComments: {{ $jmespath($json.comments, '[].{comment: comment, replies: replies[].reply}') \n   .map(item => ({\n     comment: item.comment || '',\n     replies: (item.replies || []).filter(r => r !== null)\n   })) \n   .toJsonString() }}\n"
            }
          ]
        },
        "options": {}
      },
      "id": "c79a1286-2c82-4a8e-86f0-53a9932c0cf7",
      "name": "Reduce Objects to 1",
      "type": "n8n-nodes-base.set",
      "position": [
        2816,
        352
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "postdata"
            }
          ]
        },
        "options": {}
      },
      "id": "cb14d13d-4574-40d7-96a4-c6c87d01b91b",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        3040,
        352
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.postdata.join('\\n\\n') }}",
        "needsFallback": true,
        "options": {
          "systemMessage": "You are an expert marketing research assistant. Your task is to analyze Reddit posts and comments from a specific subreddit and produce clear, structured, and actionable insights for marketers.  \n\nThe data you receive will contain:\n- Post title, description, URL\n- Upvotes and comment counts\n- Top-level comments and replies\n\nYour analysis must focus on extracting what is most useful for marketers, brand managers, or product teams.\n\nProvide your output in the following structured sections:\n\n1. **Summary of Community Discussion**\n   - Briefly summarize the main themes/topics people are discussing in the subreddit during this period.\n   - Highlight if conversations are trending around specific products, pain points, or cultural shifts.\n\n2. **Positive Sentiment & Praise**\n   - Identify what users are praising (products, features, services, brands).\n   - Include examples of exact customer language when possible.\n\n3. **Negative Sentiment & Complaints**\n   - Highlight recurring complaints or frustrations.\n   - Emphasize product weaknesses, unmet needs, or service issues.\n\n4. **Emerging Trends & Opportunities**\n   - Point out new behaviors, brands, or ideas gaining traction.\n   - Suggest opportunities where a brand could position itself, engage, or create content.\n\n5. **Competitor Mentions**\n   - List brands, companies, or products being discussed.\n   - Summarize user perception of each (positive/negative/neutral).\n\n6. **Actionable Insights for Marketers**\n   - Translate findings into practical recommendations for marketing campaigns, messaging, product development, or customer engagement.\n   - Keep it concise and actionable.\n\n7. **Key Quotes**\n   - Provide a few representative user quotes (short, impactful) that capture the voice of the customer.\n\nFormatting Guidelines:\n- Use clear markdown headings (##).\n- Be concise but insightful.\n- Avoid repeating the raw data; instead, distill it into insights.\n- Assume the reader is a busy marketer who needs quick takeaways and actionable direction.\n\nYour output should be professional, marketing-focused, and it should be in JSON format. I want two parameters, one called 'title' and the second one called 'paragraph'. Everything in the paragraph must be in markdown format. Showing you an example below.\n\n{\n  \"Title\": \"Hello World!\",\n  \"Paragraph\": \"Welcome to my Page!\"\n}\n\n"
        }
      },
      "id": "8e5a5213-262a-4dfb-bd90-54b2a4883028",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3376,
        320
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "dfd17b48-1b8b-4aba-8f31-2e62f2174299",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3440,
        544
      ],
      "typeVersion": 1,
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Get most recent reddit posts. Maybe as the input we can put a chat node to type in the subreddit name.\n",
        "height": 496,
        "width": 992,
        "color": 7
      },
      "id": "c3f93233-ef4a-40a5-b317-bd39ac13dbb8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        208
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## Pass Posts to Bright Data to get comment and upvote data",
        "height": 480,
        "width": 1504,
        "color": 7
      },
      "id": "62fd63b0-7381-46ca-96f9-2afb9882cf39",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        208
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## Prep output for LLM",
        "height": 480,
        "width": 640,
        "color": 7
      },
      "id": "8ee86614-8dcd-4799-8f9c-67dbf9c3fdf2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2528,
        208
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## Convert posts to summary",
        "height": 480,
        "width": 544,
        "color": 7
      },
      "id": "78de3e7d-b840-40ae-ac3e-f27187de1fcc",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3200,
        208
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        3312,
        496
      ],
      "id": "4d70a50d-d2b0-491f-acd1-fbb588145570",
      "name": "Google Gemini Chat Model1",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "id": "1cd1e285-ccbc-4593-be24-5eb82166f812",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -16,
        464
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "subreddit-field",
              "name": "subreddit",
              "type": "string",
              "value": "SkincareAddiction"
            }
          ]
        },
        "options": {}
      },
      "id": "eaf8b9b3-08ad-4964-85cd-67cd612927c0",
      "name": "Set Subreddit",
      "type": "n8n-nodes-base.set",
      "position": [
        192,
        464
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "url": "={{ 'https://www.reddit.com/r/' + $json.subreddit + '.rss' }}",
        "options": {}
      },
      "id": "266fcec8-2209-4011-9c43-8491ca05fe8b",
      "name": "RSS Read",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        400,
        464
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "11be4491-e850-4cec-8401-45592419e30f",
              "name": "url",
              "type": "string",
              "value": "={{ $json.link }}"
            }
          ]
        },
        "options": {}
      },
      "id": "45ca30db-ccbb-44d0-a013-c2896780cce2",
      "name": "Extract URLs",
      "type": "n8n-nodes-base.set",
      "position": [
        608,
        464
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "id": "26671b64-1baf-46bb-9f9f-b6199d4cc31a",
      "name": "Aggregate URLs to Single Object",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        800,
        464
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "operation": "triggerCollectionByUrl",
        "dataset_id": {
          "__rl": true,
          "value": "gd_lvz8ah06191smkebj4",
          "mode": "list",
          "cachedResultName": "Reddit- Posts"
        },
        "urls": "={{ $json.data.toJsonString() }}",
        "requestOptions": {}
      },
      "id": "1fe1a71e-f9d5-45fc-9b69-6ba5c8fc2d26",
      "name": "Initiate batch extraction from URL",
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "position": [
        1184,
        464
      ],
      "typeVersion": 1,
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pageId": {
          "__rl": true,
          "value": "=25b7080884b3806dbd9ce94a739ed133",
          "mode": "id"
        },
        "title": "={{ $json.Title }}",
        "simple": false,
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        4096,
        192
      ],
      "id": "b60a1fe1-bcc4-460b-a99b-4b6ae8bf5791",
      "name": "Create a page",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 30
      },
      "id": "6279f41b-082c-4b7e-8fc1-ac021ce1c53e",
      "name": "Wait 30 seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        2096,
        480
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// N8N Code to convert only the Paragraph field to Notion blocks\n// Input: Array with Title and Paragraph fields\n// Output: Notion blocks from Paragraph content only\n\nfunction markdownToNotionBlocks(markdown) {\n    const lines = markdown.split('\\n');\n    const blocks = [];\n    let currentList = null;\n    \n    function parseRichText(text) {\n        const richText = [];\n        const regex = /(\\*\\*|__)(.*?)\\1|(_|\\*)(.*?)\\3|(`)(.*?)\\5|(\\[)(.*?)\\]\\((.*?)\\)/g;\n        let lastIndex = 0;\n        \n        text.replace(regex, (match, bold1, boldText, italic1, italicText, code1, codeText, link1, linkText, linkUrl, index) => {\n            if (index > lastIndex) {\n                richText.push({ text: { content: text.slice(lastIndex, index) } });\n            }\n            \n            if (boldText) {\n                richText.push({ text: { content: boldText }, annotations: { bold: true } });\n            } else if (italicText) {\n                richText.push({ text: { content: italicText }, annotations: { italic: true } });\n            } else if (codeText) {\n                richText.push({ text: { content: codeText }, annotations: { code: true } });\n            } else if (linkText) {\n                richText.push({ text: { content: linkText, link: { url: linkUrl } } });\n            }\n            \n            lastIndex = index + match.length;\n        });\n        \n        if (lastIndex < text.length) {\n            richText.push({ text: { content: text.slice(lastIndex) } });\n        }\n        \n        return richText.length > 0 ? richText : [{ text: { content: text } }];\n    }\n    \n    for (const line of lines) {\n        // Reset currentList for non-list items\n        if (!line.startsWith('- ') && !line.startsWith('*   ')) {\n            currentList = null;\n        }\n        \n        if (line.startsWith('# ')) {\n            blocks.push({ type: 'heading_1', heading_1: { rich_text: parseRichText(line.slice(2)) } });\n        } else if (line.startsWith('## ')) {\n            blocks.push({ type: 'heading_2', heading_2: { rich_text: parseRichText(line.slice(3)) } });\n        } else if (line.startsWith('### ')) {\n            blocks.push({ type: 'heading_3', heading_3: { rich_text: parseRichText(line.slice(4)) } });\n        } else if (line.startsWith('- ')) {\n            blocks.push({ type: 'bulleted_list_item', bulleted_list_item: { rich_text: parseRichText(line.slice(2)) } });\n        } else if (line.startsWith('*   ')) {\n            // Handle the specific format from your data (*   **text**)\n            blocks.push({ type: 'bulleted_list_item', bulleted_list_item: { rich_text: parseRichText(line.slice(4)) } });\n        } else if (line.startsWith('> ')) {\n            blocks.push({ type: 'quote', quote: { rich_text: parseRichText(line.slice(2)) } });\n        } else if (line.startsWith('```')) {\n            const codeLines = [];\n            let i = lines.indexOf(line) + 1;\n            while (i < lines.length && !lines[i].startsWith('```')) {\n                codeLines.push(lines[i]);\n                i++;\n            }\n            blocks.push({ type: 'code', code: { rich_text: [{ text: { content: codeLines.join('\\n') } }] } });\n        } else if (line.trim()) {\n            blocks.push({ type: 'paragraph', paragraph: { rich_text: parseRichText(line) } });\n        }\n    }\n    \n    return blocks;\n}\n\n// Get the current item's data\ntry {\n    // Extract only the Paragraph field from the input\n    const paragraphContent = $json.Paragraph || '';\n    \n    // Convert the paragraph markdown to Notion blocks\n    const notionBlocks = markdownToNotionBlocks(paragraphContent);\n    \n    return {\n        blocks: notionBlocks\n    };\n    \n} catch (error) {\n    console.error('Error converting to Notion blocks:', error);\n    return {\n        blocks: [{\n            type: 'paragraph',\n            paragraph: {\n                rich_text: [{\n                    text: { content: 'Error converting markdown to Notion blocks: ' + error.message }\n                }]\n            }\n        }]\n    };\n}"
      },
      "id": "65f8e14b-8232-48d6-b116-f81005e05151",
      "name": "Md to Notion Blocks v3",
      "type": "n8n-nodes-base.code",
      "position": [
        4128,
        448
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.notion.com/v1/blocks/{{ $json.pageId }}/children ",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "notionApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"children\": {{ $json.requestBody.children.toJsonString() }}\n}",
        "options": {}
      },
      "id": "42007e51-1144-4978-8345-def95fd4a67c",
      "name": "Add blocks as Children",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4976,
        304
      ],
      "typeVersion": 4.2,
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        4448,
        304
      ],
      "id": "89fab8b9-fab1-42cb-ab27-89b153675cc1",
      "name": "Merge"
    },
    {
      "parameters": {
        "content": "## Post the insights into dedicated notion workspaces.\n",
        "height": 624,
        "width": 1520,
        "color": 7
      },
      "id": "619eee7a-a993-424b-a740-6d19c64e1d42",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3792,
        112
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "jsCode": "// N8N JavaScript Code to parse AI Agent output\n// Input: Array with JSON string in \"output\" field\n// Output: {Title: string, Paragraph: string}\n\n// Get the input data from the previous node\nconst inputData = $input.all();\n\n// Helper function to clean and fix common JSON issues\nfunction cleanJsonString(str) {\n  return str\n    // Remove markdown code block formatting\n    .replace(/```json\\n?/g, '')\n    .replace(/\\n?```$/g, '')\n    // Fix common JSON issues\n    .replace(/\\n/g, '\\\\n')  // Escape actual newlines in strings\n    .replace(/\\t/g, '\\\\t')  // Escape tabs\n    .replace(/\\r/g, '\\\\r')  // Escape carriage returns\n    // Fix unescaped quotes in strings (basic attempt)\n    .replace(/(?<!\\\\)\"/g, match => {\n      // This is a simplified approach - may need refinement\n      return '\\\\\"';\n    })\n    .replace(/\\\\\"/g, '\"')  // Restore properly escaped quotes\n    .replace(/\"([^\"]*)\":/g, '\"$1\":'); // Ensure property names are quoted\n}\n\n// Process each item in the input\nconst processedItems = inputData.map(item => {\n  try {\n    // Extract the output string from the input item\n    let outputString = item.json.output;\n    \n    console.log('Original output string:', outputString.substring(0, 200) + '...');\n    \n    // Clean the JSON string\n    let cleanJsonString = cleanJsonString(outputString);\n    \n    console.log('Cleaned JSON string:', cleanJsonString.substring(0, 200) + '...');\n    \n    // Try to parse the JSON string\n    const parsedData = JSON.parse(cleanJsonString);\n    \n    // Extract title and paragraph\n    const title = parsedData.Title || '';\n    const paragraph = parsedData.Paragraph || '';\n    \n    // Return the formatted object\n    return {\n      json: {\n        Title: title,\n        Paragraph: paragraph\n      }\n    };\n    \n  } catch (error) {\n    // If JSON parsing fails, try a regex approach to extract Title and Paragraph\n    try {\n      const outputString = item.json.output;\n      \n      // Use regex to extract Title and Paragraph\n      const titleMatch = outputString.match(/\"Title\":\\s*\"([^\"]+)\"/);\n      const paragraphMatch = outputString.match(/\"Paragraph\":\\s*\"([\\s\\S]*?)\"\\s*}/);\n      \n      const title = titleMatch ? titleMatch[1] : 'No Title Found';\n      let paragraph = paragraphMatch ? paragraphMatch[1] : 'No Paragraph Found';\n      \n      // Clean up the paragraph (unescape characters)\n      paragraph = paragraph\n        .replace(/\\\\n/g, '\\n')\n        .replace(/\\\\t/g, '\\t')\n        .replace(/\\\\\"/g, '\"')\n        .replace(/\\\\\\\\/g, '\\\\');\n      \n      return {\n        json: {\n          Title: title,\n          Paragraph: paragraph\n        }\n      };\n      \n    } catch (regexError) {\n      // Handle both parsing errors\n      console.error('JSON parsing error:', error);\n      console.error('Regex extraction error:', regexError);\n      \n      return {\n        json: {\n          Title: 'Error',\n          Paragraph: 'Failed to parse JSON data. Original error: ' + error.message + '. Raw data: ' + item.json.output.substring(0, 500) + '...'\n        }\n      };\n    }\n  }\n});\n\nreturn processedItems;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3888,
        320
      ],
      "id": "7a5784bc-4abf-40fd-87c9-46ace3625e3f",
      "name": "Convert output to Title and Content"
    },
    {
      "parameters": {
        "jsCode": "// N8N Code to properly format the request body for Notion API\n// Input: Merged data from page creation and blocks\n// Output: Formatted request data with pageId and properly structured requestBody\n\ntry {\n    // Get all input items from the merge\n    const inputData = $input.all();\n    \n    console.log('Input data length:', inputData.length);\n    console.log('First item:', JSON.stringify(inputData[0], null, 2));\n    if (inputData.length > 1) {\n        console.log('Second item:', JSON.stringify(inputData[1], null, 2));\n    }\n    \n    // Extract page ID from the first item (page creation response)\n    const pageId = inputData[0].json.id;\n    \n    // Extract blocks from the second item (blocks conversion result)\n    let blocks = [];\n    if (inputData.length > 1 && inputData[1].json.blocks) {\n        blocks = inputData[1].json.blocks;\n    } else if (inputData[0].json.blocks) {\n        // Fallback: check if blocks are in the first item\n        blocks = inputData[0].json.blocks;\n    }\n    \n    console.log('Extracted pageId:', pageId);\n    console.log('Extracted blocks count:', blocks.length);\n    \n    // Create the properly formatted request body for Notion API\n    const requestBody = {\n        children: blocks\n    };\n    \n    // Return the data needed for the HTTP request\n    return {\n        pageId: pageId,\n        requestBody: requestBody,\n        blocks: blocks,\n        id: pageId\n    };\n    \n} catch (error) {\n    console.error('Error formatting request body:', error);\n    return {\n        pageId: 'error',\n        requestBody: { children: [] },\n        error: error.message,\n        blocks: [],\n        id: 'error'\n    };\n}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4720,
        304
      ],
      "id": "c9e20608-0b5d-4d7f-8842-fb352336141b",
      "name": "Format for Block API"
    }
  ],
  "connections": {
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Check the status of a batch extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Snapshot Again for Success": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the status of a batch extraction": {
      "main": [
        [
          {
            "node": "Check if Batch Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Batch Ready": {
      "main": [
        [
          {
            "node": "Download the snapshot content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the snapshot content": {
      "main": [
        [
          {
            "node": "Extract Essential Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Essential Data": {
      "main": [
        [
          {
            "node": "Reduce Objects to 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reduce Objects to 1": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Convert output to Title and Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set Subreddit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Subreddit": {
      "main": [
        [
          {
            "node": "RSS Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read": {
      "main": [
        [
          {
            "node": "Extract URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URLs": {
      "main": [
        [
          {
            "node": "Aggregate URLs to Single Object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate URLs to Single Object": {
      "main": [
        [
          {
            "node": "Initiate batch extraction from URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initiate batch extraction from URL": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a page": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30 seconds": {
      "main": [
        [
          {
            "node": "Check Snapshot Again for Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Md to Notion Blocks v3": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Add blocks as Children": {
      "main": [
        []
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Format for Block API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert output to Title and Content": {
      "main": [
        [
          {
            "node": "Md to Notion Blocks v3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create a page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format for Block API": {
      "main": [
        [
          {
            "node": "Add blocks as Children",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Reddit-Insights-N8N. Uses @brightdata/n8n-nodes-brightdata, agent, lmChatGoogleGemini, rssFeedRead. Scheduled trigger; 29 nodes.

Source: https://gist.github.com/kichuman28/5f0dc6c3b5eaf2377442964faa096630 — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

RSS Feed Read, @Brightdata/N8N Nodes Brightdata, Agent +4
AI & RAG

LinkedIn_Job_Hunt_and_Cover_Letter. Uses outputParserStructured, outputParserAutofixing, googleDrive, agent. Scheduled trigger; 85 nodes.

Output Parser Structured, Output Parser Autofixing, Google Drive +6
AI & RAG

Automatically scan major financial newswires for biotech catalyst events, score them with AI sentiment analysis, and surface ranked trade candidates — all without manual monitoring.

RSS Feed Read, Data Table, HTTP Request +4
AI & RAG

This project is an automated news publisher for LinkedIn. It uses RSS feeds to fetch news, processes the content with the Gemini API to generate precise summaries, and automatically publishes to Linke

Agent, Google Gemini Chat, RSS Feed Read +4
AI & RAG

This workflow is designed for Japanese-speaking professionals, and learners who want to efficiently stay up to date with practical productivity, lifehack, and efficiency-related insights from Japanese

RSS Feed Read, Chain Llm, Google Gemini Chat +7