{
  "id": "y5gejWMNwzlGytFB",
  "name": "ASKREDDIT: PHASE 1-CONFESSION",
  "tags": [],
  "nodes": [
    {
      "id": "9c8ba3f0-8f62-476e-8f0d-1af27da4c271",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -900,
        -320
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1fbba9af-2a49-43f9-aeae-fc5b009e51a9",
      "name": "Get AskReddit Posts",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -680,
        -320
      ],
      "parameters": {
        "url": "https://www.reddit.com/r/confession/hot.json?limit=30",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "n8n-askreddit-scraper"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "301ccc14-a647-4e4b-918b-6d2ffe0bac33",
      "name": "Filter AskReddit Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -460,
        -320
      ],
      "parameters": {
        "jsCode": "return items[0].json.data.children\n  .filter(post => {\n    const title = post.data.title.toLowerCase();\n    return !title.includes(\"trump\") &&\n           !title.includes(\"president\") &&\n           !title.includes(\"war\") &&\n           !title.includes(\"israel\");\n  })\n  .map(post => {\n    const data = post.data;\n    return {\n      json: {\n        post_id: data.id,\n        title: data.title,\n        selftext:data.selftext,\n        score: data.score,\n        num_comments: data.num_comments,\n        over_18: data.over_18 // to filter NSFW later\n      }\n    };\n  });\n"
      },
      "typeVersion": 2
    },
    {
      "id": "20b6d540-0241-4fcd-a5d1-9bd836953edd",
      "name": "Filter for Virality Potential",
      "type": "n8n-nodes-base.code",
      "position": [
        -240,
        -320
      ],
      "parameters": {
        "jsCode": "return items.filter(item => {\n  const { score, num_comments, over_18 } = item.json;\n  return score > 60 && num_comments > 40 && over_18 === false;\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "de14ca44-907d-4fc5-a67f-66a76318cec5",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        140,
        -600
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "78d810f4-8d49-440f-975f-1520d4a41714",
      "name": "Filter Duplicates",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        -600
      ],
      "parameters": {
        "jsCode": "const inputData = $input.all(); // gets all input items\n\nconst redditPosts = inputData.filter(i => i.json.post_id);\nconst existingRows = inputData.filter(i => i.json[\"Reddit Post ID\"]);\n\nconst existingPostIds = new Set(\n  existingRows\n    .map(row => row.json[\"Reddit Post ID\"])\n    .filter(id => id !== undefined && id !== null)\n    .map(id => id.toString())\n);\n\nreturn redditPosts.filter(item =>\n  !existingPostIds.has(item.json.post_id.toString())\n);\n"
      },
      "typeVersion": 2
    },
    {
      "id": "91f6516f-3fd6-42ab-9f3d-815159158e76",
      "name": "Add Numbering",
      "type": "n8n-nodes-base.code",
      "position": [
        580,
        -600
      ],
      "parameters": {
        "jsCode": "let count = 1;\nreturn items.map(item => {\n  return {\n    json: {\n      number: count++,\n      ...item.json\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "82c8e67f-3f68-4aaa-9616-eb2ae9da3541",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1040,
        -580
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "f3fa1876-7a35-4307-989a-1b2b5df7ff66",
      "name": "GIVE VIRALITY SCORE",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        760,
        -300
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "assistant",
              "content": "You're an expert in viral content analysis. Rate the virality potential (1\u201310) of this Reddit question based on emotional engagement, curiosity, and relatability: {{$json.title}}. Respond with just the number.\n"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "357ae2b6-972d-432e-a6e4-ef9f291717ba",
      "name": "Add Virality Score",
      "type": "n8n-nodes-base.code",
      "position": [
        1280,
        -580
      ],
      "parameters": {
        "jsCode": "return items.map((item, index) => {\n  return {\n    json: {\n      ...item.json,\n      virality_score: item.json.message?.content.trim()\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "65d1201d-59c6-43af-a4da-8d45a02fac9c",
      "name": "Filter by Score",
      "type": "n8n-nodes-base.code",
      "position": [
        1520,
        -580
      ],
      "parameters": {
        "jsCode": "return items.filter(item => {\n  const score = parseInt(item.json.virality_score, 10);\n  return score >= 6;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f37cf1c6-2d0a-4183-a702-6bbf87eaf593",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -1425
      ],
      "parameters": {
        "color": 5,
        "width": 3000,
        "height": 1340,
        "content": "THIS IS THE FIRST PHASE. IT SCRAPS REDDIT DATA AND WRITES IN EXCEL"
      },
      "typeVersion": 1
    },
    {
      "id": "95197a4e-63c2-4e88-af7c-7a9e2d0a57de",
      "name": "Write confession DETAILS",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1720,
        -580
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{new Date().toISOString().slice(0, 10)}}",
            "TYPE": "CONFESSION",
            "Number": "={{ $json.number }}",
            "Status": "TODO",
            "Upvotes": "={{ $json.score }}",
            "Answer 1": "={{ $json.selftext }}",
            "Comments": "={{ $json.num_comments }}",
            "Question": "={{ $json.title }}",
            "Reddit Post ID": "={{ $json.post_id }}",
            "Virality Score": "={{ $json.virality_score }}"
          },
          "schema": [
            {
              "id": "Number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Question",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Question",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Virality Score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Virality Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Upvotes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Upvotes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Comments",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Reddit Post ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Reddit Post ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Answer 1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Answer 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Answer 2",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Answer 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Answer 3",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Answer 3",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Answer 4",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Answer 4",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Answer 5",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Answer 5",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Answer 6",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Answer 6",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AUDIO ID",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "AUDIO ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YouTube Video Title",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "YouTube Video Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YouTube Description",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "YouTube Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YouTube Tags",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "YouTube Tags",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YouTube Video ID",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "YouTube Video ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YouTube Link",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "YouTube Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "CTR (Click-Through Rate)",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "CTR (Click-Through Rate)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Average View Duration",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Average View Duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Audience Retention %",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Audience Retention %",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Likes",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments Count",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Comments Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Thumbnail Version",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Thumbnail Version",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Title Version",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Title Version",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Optimization Notes",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Optimization Notes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Updated",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Last Updated",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TYPE",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "TYPE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1850949286,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GXJPrrD5AcZQQV_LG_NadDnWfGFUdQG0g_be-xdEtW4/edit#gid=1850949286",
          "cachedResultName": "ASKREDDIT"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1GXJPrrD5AcZQQV_LG_NadDnWfGFUdQG0g_be-xdEtW4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GXJPrrD5AcZQQV_LG_NadDnWfGFUdQG0g_be-xdEtW4/edit?usp=drivesdk",
          "cachedResultName": "n8n Resume Studio"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "da7d00b2-64dd-46ec-a90f-f355b129fef5",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        -260
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1850949286,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GXJPrrD5AcZQQV_LG_NadDnWfGFUdQG0g_be-xdEtW4/edit#gid=1850949286",
          "cachedResultName": "ASKREDDIT"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1GXJPrrD5AcZQQV_LG_NadDnWfGFUdQG0g_be-xdEtW4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GXJPrrD5AcZQQV_LG_NadDnWfGFUdQG0g_be-xdEtW4/edit?usp=drivesdk",
          "cachedResultName": "n8n Resume Studio"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.5
    },
    {
      "id": "09d2099d-1610-4833-869c-e4785b95234f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -920,
        -1340
      ],
      "parameters": {
        "width": 960,
        "height": 660,
        "content": "\ud83d\udcdd Description\n\nThis workflow automates the collection, filtering, and scoring of trending AskReddit posts for viral potential. It pulls posts from Reddit, removes duplicates, calculates a custom virality score, and writes the final candidates into Google Sheets for later use in content creation.\n\nThis is Phase 1 of the AskReddit \u2192 YouTube Shorts automation pipeline. It prepares clean, high-quality data that can be used in the next phases (script generation, AI video creation, and publishing).\n\n\u2699\ufe0f Setup Steps\n\nImport Workflow into your n8n instance.\n\nReddit API:\n\nAdd your Reddit API credentials in the \"Get AskReddit Posts\" node.\n\nGoogle Sheets:\n\nConnect your Google account.\n\nPoint the \"Write Candidates\" node to your target Google Sheet.\n\nVirality Scoring:\n\nThe \"Add Virality Score\" node assigns weights (e.g., upvotes, comments).\n\nAdjust the scoring logic as needed for your niche.\n\nRun Workflow:\n\nExecute manually or schedule with Cron.\n\nVerify that trending AskReddit posts appear in your sheet, scored and cleaned."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": "{\"executionOrder\":\"v1\"}",
  "versionId": "3a9f7928-6531-4cc5-bbb4-ce8c71a73ad5",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Filter Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Add Virality Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Numbering": {
      "main": [
        [
          {
            "node": "GIVE VIRALITY SCORE",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter by Score": {
      "main": [
        [
          {
            "node": "Write confession DETAILS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Duplicates": {
      "main": [
        [
          {
            "node": "Add Numbering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Virality Score": {
      "main": [
        [
          {
            "node": "Filter by Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GIVE VIRALITY SCORE": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get AskReddit Posts": {
      "main": [
        [
          {
            "node": "Filter AskReddit Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter AskReddit Data": {
      "main": [
        [
          {
            "node": "Filter for Virality Potential",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write confession DETAILS": {
      "main": [
        []
      ]
    },
    "Filter for Virality Potential": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Get AskReddit Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}