{
  "id": "etfXGaxuiLBSiZ2M",
  "meta": {
    "templateId": "2978",
    "templateCredsSetupCompleted": true
  },
  "name": "Find trendy Linkedin post ideas from Reddit posts",
  "tags": [],
  "nodes": [
    {
      "id": "e9a000b6-2f35-4928-a8d8-aa2d8cc27513",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1620,
        -1200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f78fbea9-5f7f-4a88-bde1-7c3f01613892",
      "name": "Output The Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3480,
        -340
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "fgf",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "fgf",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Post Content",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Post Content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Comments",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Insights",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Insights",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Linkedin post ideas",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Linkedin post ideas",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "fgf"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Create spreadsheet').item.json.spreadsheetUrl }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "72b30080-e1f2-48b4-b816-ff43542cc6f1",
      "name": "Get Posts",
      "type": "n8n-nodes-base.reddit",
      "position": [
        -320,
        -680
      ],
      "parameters": {
        "keyword": "={{ $('On form submission').item.json['What to search for in the subreddit'] }}",
        "operation": "search",
        "subreddit": "={{ $('On form submission').item.json.Subreddit }}",
        "additionalFields": {}
      },
      "credentials": {
        "redditOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e0729fbb-c530-46da-b8af-e4685d415dd9",
      "name": "Get many comments in a post",
      "type": "n8n-nodes-base.reddit",
      "position": [
        340,
        -760
      ],
      "parameters": {
        "postId": "={{ $json.id }}",
        "resource": "postComment",
        "operation": "getAll",
        "subreddit": "={{ $json.subreddit }}"
      },
      "credentials": {
        "redditOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4c00ccd3-a984-4136-a1d1-21c2b61c53ba",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        100,
        -760
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "00d17970-3195-4290-bb02-9956f31ecc8f",
      "name": "Suggest post topics",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2480,
        -740
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a senior LinkedIn content strategist.\n\n### Input  \nAnalysisMarkdown: |\n {{ $json.output }}\n\n### Tasks  \n1. **Extract Insights**  \n   \u2022 Parse the supplied Markdown to understand the central theme, five pains, and the synthesis section.  \n   \u2022 Identify which pains or angles will resonate most with a professional (B2B / SaaS / tech) audience.\n\n2. **Generate Post Topics**  \n   \u2022 Propose **3\u20135 distinct LinkedIn post topics** that tackle the most compelling pains or insights.  \n   \u2022 Vary the angles (e.g., tactical advice, thought-leadership, myth-busting, data-driven take).\n\n3. **Outline Key Points**  \n   For **each** topic provide:  \n   \u2022 **Headline** \u2013 \u2264 70 characters, designed to stop the scroll.  \n   \u2022 **Key Points** \u2013 3\u20134 concise bullets (\u2264 25 words each) covering what the post should include.  \n   \u2022 **Hook** \u2013 1-sentence opener to grab attention (\u2264 30 words).  \n   \u2022 **CTA** \u2013 1-sentence question or prompt that invites comments.\n\n### Output (Markdown)"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "aa7f4cd0-c9dd-42c4-8b93-ebac8aa1598d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2420,
        -940
      ],
      "parameters": {
        "width": 840,
        "height": 720,
        "content": "# Generate Post ideas"
      },
      "typeVersion": 1
    },
    {
      "id": "1a99fdaa-6857-4210-a695-71ce531c1fa0",
      "name": "Generate insights",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1620,
        -1360
      ],
      "parameters": {
        "text": "=You are an expert content analyst.\n\n### Input\nPostContent: |\n  {{ $json.postContent }}\n\nCommentContentJSON: |\n  {{ $json.commentText }}\n\n### Tasks\n1. **Central Theme**  \n   Summarize the main topic or question driving the discussion (\u2264 30 words).\n\n2. **Pain-Point Extraction**  \n   \u2022 Scan the post and comments for frustrations, blockers, or unmet needs.  \n   \u2022 List **exactly five** pains, ordered by frequency.  \n   \u2022 For each pain, add a short supporting quote (\u2264 20 words).\n\n3. **Insight Synthesis**  \n   \u2022 Write a 150\u2013200 word narrative capturing consensus, disagreements, surprising angles, data points, or anecdotes.  \n   \u2022 Tag the overall sentiment (e.g., \u201coptimistic\u201d, \u201cskeptical\u201d, \u201cfrustrated\u201d).\n\n4. **LinkedIn Opportunity**  \n   \u2022 Propose one punchy LinkedIn post title (\u2264 70 characters) that tackles the top pain.  \n   \u2022 Give three concise bullet points to cover (each \u2264 25 words).  \n   \u2022 Suggest a one-sentence CTA to spark discussion.\n\n5. **Relevance Check**  \n   Explain in \u2264 40 words why this topic matters right now to B2B / SaaS / tech professionals.\n\n### Output (strict Markdown)\n\n## Central Theme\n<central theme>\n\n## Pain Points\n1. **<pain #1>**  \n   - Quote: \u201c<quote>\u201d\n2. **<pain #2>**  \n   - Quote: \u201c<quote>\u201d\n3. **<pain #3>**  \n   - Quote: \u201c<quote>\u201d\n4. **<pain #4>**  \n   - Quote: \u201c<quote>\u201d\n5. **<pain #5>**  \n   - Quote: \u201c<quote>\u201d\n\n## Insights\n<150\u2013200 word synthesis paragraph>\n\n## LinkedIn Angle\n**Headline:** <LinkedIn title>\n\n- <bullet 1>  \n- <bullet 2>  \n- <bullet 3>\n\n**CTA:** <call to action>\n\n## Relevance\n<why it\u2019s timely>\n\n### Constraints\n* Use **only** the supplied text\u2014no external knowledge.  \n* Keep quotes verbatim but truncate with \u201c\u2026\u201d if needed.  \n* Preserve anonymity (no usernames).  \n* Follow the exact Markdown structure above\u2014no extra sections or commentary.",
        "agent": "conversationalAgent",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "1a203a66-b727-41f4-b215-d321860720e7",
      "name": "Filter only posts with comments",
      "type": "n8n-nodes-base.filter",
      "position": [
        -100,
        -680
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b7132a05-1f02-4d2d-9eba-d23d636c1f09",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.num_comments }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "cf8f8254-9295-43ca-9e3f-5a7f348eb3ac",
      "name": "Aggregate comments to single field",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        560,
        -760
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "body"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b2a4f6ad-1b1f-4d15-a872-fc96fb562cfc",
      "name": "Construct post with comment object",
      "type": "n8n-nodes-base.set",
      "position": [
        780,
        -760
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "74de4fe8-9e37-40c1-86b5-d646bedaaf52",
              "name": "commentText",
              "type": "array",
              "value": "={{ $json.body }}"
            },
            {
              "id": "67bdb6fe-36d1-4357-89f9-855282c4ba70",
              "name": "postId",
              "type": "string",
              "value": "={{$(\"Loop Over Items\").item.json.id}}"
            },
            {
              "id": "247b3e29-6048-484a-a5fe-388bd54e635d",
              "name": "postContent",
              "type": "string",
              "value": "={{$(\"Loop Over Items\").item.json.selftext}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "60991de9-ad29-484c-9233-966cc1980a03",
      "name": "Merge insights with post content and comments",
      "type": "n8n-nodes-base.merge",
      "position": [
        1960,
        -1080
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "595870aa-09d4-4fbe-94a3-c6ccf2896b41",
      "name": "Construct post ideas",
      "type": "n8n-nodes-base.set",
      "position": [
        2840,
        -740
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "77032901-551e-4260-be47-fe90ed5906d0",
              "name": "postIdeas",
              "type": "string",
              "value": "={{ $json.message.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0a26ec15-eeaa-421c-9007-6e88fcf49b48",
      "name": "Construct insights",
      "type": "n8n-nodes-base.set",
      "position": [
        2800,
        -520
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "adbb373d-9644-41d6-ab15-7ff127de3f1d",
              "name": "contentAnalysis",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "04742d30-475e-4c46-83eb-a06fa1a0bb3c",
              "name": "commentText",
              "type": "array",
              "value": "={{ $json.commentText }}"
            },
            {
              "id": "1e152425-8fed-4d06-a208-193fa9324d4d",
              "name": "postId",
              "type": "string",
              "value": "={{ $json.postId }}"
            },
            {
              "id": "126fd80c-cf2b-48ca-b581-5400bf491bbf",
              "name": "postContent",
              "type": "string",
              "value": "={{ $json.postContent }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "655255e4-3395-4e41-923c-7dc7c32ef3b4",
      "name": "Merge insights and post suggestions",
      "type": "n8n-nodes-base.merge",
      "position": [
        3040,
        -660
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "a99b51fd-3499-428c-a30d-6c5ea586ee47",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -1420
      ],
      "parameters": {
        "color": 4,
        "width": 840,
        "height": 720,
        "content": "# Generate Insights"
      },
      "typeVersion": 1
    },
    {
      "id": "5019794e-ddd2-4697-8c86-733f5018a4a7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -940
      ],
      "parameters": {
        "color": 3,
        "width": 1300,
        "height": 700,
        "content": "# Fetch Posts and Comments"
      },
      "typeVersion": 1
    },
    {
      "id": "728fd2b7-66a3-4c48-a286-70611d79f5cf",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1080,
        -1020
      ],
      "parameters": {
        "options": {},
        "formTitle": "Post ideas generation",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Subreddit",
              "placeholder": "marketing",
              "requiredField": true
            },
            {
              "fieldLabel": "What to search for in the subreddit"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9e73f274-0d0d-41a0-83e8-3cd9118cdc57",
      "name": "Create spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -640,
        -1100
      ],
      "parameters": {
        "title": "=post_ideas_{{ $json.Subreddit }}_{{ $json['What to search for in the subreddit'] }}_{{$now.format('yyyy_MM_dd_HH_mm_ss')}}",
        "options": {},
        "resource": "spreadsheet"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "4370f63c-29c3-4fa4-bde7-9bd6af1616c3",
      "name": "Prepare output columns",
      "type": "n8n-nodes-base.set",
      "position": [
        3220,
        -580
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d31c7eaf-ef32-4f47-ac9d-4726737ba749",
              "name": "Post Content",
              "type": "string",
              "value": "={{ $json.postContent }}"
            },
            {
              "id": "02dbd93a-954d-46f4-9b44-c092bdaae529",
              "name": "Comments",
              "type": "string",
              "value": "={{ $json.commentText.join('\\n\\n\\n\\n--------\\n\\n\\n') }}"
            },
            {
              "id": "ad4491d0-6d5a-49d3-8b1e-e5def682e567",
              "name": "Insights",
              "type": "string",
              "value": "={{ $json.contentAnalysis }}"
            },
            {
              "id": "924eb630-3164-42f6-8141-89c15ee5344f",
              "name": "Linkedin post ideas",
              "type": "string",
              "value": "={{ $json.postIdeas }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "05d1102b-8638-4fcc-a009-2dfb11819258",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1240,
        -2040
      ],
      "parameters": {
        "width": 1200,
        "height": 740,
        "content": "# Find trendy Linkedin post ideas from Reddit posts\n\n## Who\u2019s it for  \nMarketers, founders, and content strategists seeking **business opportunities** by analyzing Reddit discussions. Perfect for **B2B, SaaS, and tech professionals** looking for new LinkedIn content angles.\n\n## How it works  \n1. Fetches Reddit posts & comments based on a subreddit & keyword.  \n2. Uses OpenAI (ChatGPT) to extract **pain points** and synthesize insights.  \n3. Generates **LinkedIn post ideas** with headlines, hooks, and CTAs.  \n4. Saves everything in a **Google Sheet** for easy tracking.\n\n## Setup  \n1. Connect Reddit, OpenAI, and Google Sheets credentials (no hardcoded keys).  \n2. Trigger via **Form Trigger** and enter subreddit & keyword.  \n3. Review outputs in the generated Google Sheet.\n\n## Customize  \n- Edit AI prompts to change tone or depth of insights.  \n- Add filters to target high-engagement posts.  \n- Send insights to Slack or Email.\n\n\u2705 Built for **practical content marketing automation**.  \n\ud83d\udeab Don\u2019t hardcode credentials \u2013 use n8n credentials manager."
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {},
  "versionId": "de345aef-1aef-4f86-8668-d165c5a15b75",
  "connections": {
    "Get Posts": {
      "main": [
        [
          {
            "node": "Filter only posts with comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get many comments in a post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate insights": {
      "main": [
        [
          {
            "node": "Merge insights with post content and comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate insights",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Construct insights": {
      "main": [
        [
          {
            "node": "Merge insights and post suggestions",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create spreadsheet": {
      "main": [
        [
          {
            "node": "Get Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Create spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Output The Results": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Suggest post topics": {
      "main": [
        [
          {
            "node": "Construct post ideas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Construct post ideas": {
      "main": [
        [
          {
            "node": "Merge insights and post suggestions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare output columns": {
      "main": [
        [
          {
            "node": "Output The Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many comments in a post": {
      "main": [
        [
          {
            "node": "Aggregate comments to single field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter only posts with comments": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate comments to single field": {
      "main": [
        [
          {
            "node": "Construct post with comment object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Construct post with comment object": {
      "main": [
        [
          {
            "node": "Generate insights",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge insights with post content and comments",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge insights and post suggestions": {
      "main": [
        [
          {
            "node": "Prepare output columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge insights with post content and comments": {
      "main": [
        [
          {
            "node": "Suggest post topics",
            "type": "main",
            "index": 0
          },
          {
            "node": "Construct insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}