{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "bfc28649-af1b-4dcc-ace6-31e631b04a93",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        -288
      ],
      "parameters": {
        "color": 4,
        "width": 256,
        "height": 432,
        "content": "## Get posts + comments from the choosen communities\n"
      },
      "typeVersion": 1
    },
    {
      "id": "93cf8510-9bd8-4c8f-8398-f6f42727d27b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1144,
        -288
      ],
      "parameters": {
        "color": 5,
        "height": 432,
        "content": "## Extract data\n- Content\n- comments > 50chars\n- url\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c3645f17-79b4-4b40-9a34-af6fd7c8c632",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1472,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "43f6566d-ab87-48f1-880b-8e1239fa9d41",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1600,
        208
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"opportunity\": true,\n  \"reason\": \"The user is overwhelmed managing manual booking and lead response, which can be easily automated.\",\n  \"trigger_sentence\": \"I can't keep up with replying to all DMs and booking calls manually.\",\n  \"suggested_comment\": \"I totally get that\u2014juggling messages and scheduling is exhausting. Have you looked into using automation tools to streamline that flow?\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6e740eaf-7448-4f32-b84c-60670caff939",
      "name": "Get Config",
      "type": "n8n-nodes-base.airtable",
      "position": [
        96,
        -16
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appImGQn0rh53oCPE",
          "cachedResultUrl": "https://airtable.com/appImGQn0rh53oCPE",
          "cachedResultName": "Skool comments"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblfSVVKzXJxrOXEY",
          "cachedResultUrl": "https://airtable.com/appImGQn0rh53oCPE/tblfSVVKzXJxrOXEY",
          "cachedResultName": "config"
        },
        "options": {},
        "operation": "search"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "bfa95924-c9fa-434f-9371-b7517cf3eaad",
      "name": "Extract Config",
      "type": "n8n-nodes-base.set",
      "position": [
        544,
        -16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4db9375d-ca80-4421-8025-145ddabc2ba0",
              "name": "Skool URLs",
              "type": "array",
              "value": "={{ $json['Skool URLs'].split(',').map(item => ({\n\"url\": item.replaceAll(\"\\n\",\"\").trim(),\n})) }}"
            },
            {
              "id": "97bd58cf-83b1-4ff2-bcb0-5ba6a912d26d",
              "name": "cookies",
              "type": "string",
              "value": "={{ $json.cookies.replaceAll(\"\\n\",\"\").trim() }}"
            },
            {
              "id": "b41ff8da-e638-4b21-84e0-2526ce143489",
              "name": "Domain of Activity",
              "type": "string",
              "value": "={{ $json['Domain of Activity'] }}"
            },
            {
              "id": "caf22e0b-acbc-4bfb-9be5-0102f49c10d6",
              "name": "Tools Used",
              "type": "string",
              "value": "={{ $json['Tools Used'] }}"
            },
            {
              "id": "0acc3cc2-80cf-421d-b67a-898d0d4e1f11",
              "name": "Name",
              "type": "string",
              "value": "={{ $json.Name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "62ffe1f8-383f-4fc1-952f-fc5a0d7c4bc8",
      "name": "Get Skool Posts",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        992,
        -16
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/memo23~skool-posts-with-comments-scraper/run-sync-get-dataset-items",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"commentsLimit\": 20,\n    \"cookies\":{{ $json.cookies }}\n    \"includeComments\": true,\n    \"includeMedia\": false,\n    \"itemStartDate\": \"{{$now.minus(24,'hours')}}\",\n    \"proxy\": {\n        \"useApifyProxy\": true\n    },\n   \"startUrls\": [\n       { \n        \"url\":\"{{ $json['Skool URLs'].url }}\"\n        }\n    ],\n    \"tab\": \"community\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "af39e0d1-8151-4eae-bfa3-e5f62114d1c7",
      "name": "Extract Post Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1216,
        -16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ab379ef2-7aa7-46f3-943b-134f29a192b4",
              "name": "name",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "7fa6eb26-75de-48e4-abda-82c2045e3592",
              "name": "content",
              "type": "string",
              "value": "={{ $json.metadata.content }}"
            },
            {
              "id": "97e3e1e9-2378-4caf-b8e7-301675b11518",
              "name": "comments",
              "type": "array",
              "value": "={{ $json.comments.map(item => item.post.metadata.content).filter(item => item.length>50) }}"
            },
            {
              "id": "ff6a31c4-a656-4612-9f25-4aebf8441224",
              "name": "likes",
              "type": "number",
              "value": "={{ $json.metadata.upvotes }}"
            },
            {
              "id": "f1e2cc9e-58e4-4d4e-979d-271a86a07df8",
              "name": "createdAt",
              "type": "string",
              "value": "={{ $json.createdAt }}"
            },
            {
              "id": "b3a98244-7117-42e4-b704-c24df45b3192",
              "name": "postType",
              "type": "string",
              "value": "={{ $json.postType }}"
            },
            {
              "id": "f9d85eb1-5764-437b-8ed2-89665ab6738d",
              "name": "url",
              "type": "string",
              "value": "={{ $json.url }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "282cd9dd-889e-44c9-a803-83346096a180",
      "name": "EvaluateOpportunities And Generate Comments",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1440,
        -16
      ],
      "parameters": {
        "text": "=Post content: {{ $json.content }}\nComments: {{ $json.comments }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "type": "AIMessagePromptTemplate",
              "message": "=user_domain:{{ $('Extract Config').first().json['Domain of Activity'] }}\nuser_tool: {{ $('Extract Config').first().json['Tools Used'] }}\n\n\n\ud83e\uddd1\u200d\ud83d\udcbc Role\nAct as a stealth engagement strategist who identifies precise opportunities to insert insightful, helpful comments into Skool posts and comments. Your contributions subtly demonstrate expertise in {user_domain} without explicitly promoting your own community or product.\n\n\ud83c\udfaf Task\nAnalyze a post or comment and determine whether it offers a relevant opportunity to engage with a valuable, helpful comment related to {user_domain}. Return the result as JSON.\n\n\ud83d\udccc Specifics\nOutput must follow this JSON schema:\n\njson\nCopy\nEdit\n{\n  \"opportunity\": true | false,\n  \"reason\": \"why this is or isn't a fit for {user_domain} support\",\n  \"trigger_sentence\": \"exact phrase or sentence from the post/comment indicating need\",\n  \"suggested_comment\": \"only include this if opportunity is true, respond in the same language as the original post\"\n}\nThink like a value-driven expert spotting inefficiencies or challenges where {user_domain} could help.\n\nAlways suggest {user_tool} if a tool is mentioned.\nHelping here could spark a valuable connection. Respond with heart and clarity.\n\nDo not promote yourself or your community directly. Be insightful, curious, and helpful.\n\n\ud83c\udf0d Context\nYou are using this automation to grow visibility by helping users who express challenges or frustrations that {user_domain} can solve. Your smart, relevant comments will inspire profile visits and interest in your expertise\u2014organically and trust-based.\n\n\ud83e\uddea Examples\n\u2705 Opportunity Exists\njson\nCopy\nEdit\n{\n  \"opportunity\": true,\n  \"reason\": \"The user is overwhelmed managing manual tasks, which can be streamlined using {user_tool}.\",\n  \"trigger_sentence\": \"I can't keep up with replying to all DMs and booking calls manually.\",\n  \"suggested_comment\": \"I totally get that\u2014juggling messages and scheduling is exhausting. You might want to try using a tool like user_tool}} to automate that flow and save hours each week.\"\n}\n\u274c No Opportunity\njson\nCopy\nEdit\n{\n  \"opportunity\": false,\n  \"reason\": \"The post is purely motivational with no mention of workflows, tools, or pain points that {user_domain} could solve.\",\n  \"trigger_sentence\": \"Just stay consistent and the results will come!\"\n}\n\ud83d\udcdd Notes\nTranslate suggested_comment to match the post\u2019s original language.\n\nBe helpful, not salesy.\n\nIf a tool is mentioned, always recommend {user_tool}.\n\nIf there's no clear problem or inefficiency, set \"opportunity\": false.\n\n"
            },
            {
              "message": "You're an engagement strategist"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "0448f716-a891-4677-97f7-7339b4625c84",
      "name": "Merge AI Answers With Extracted Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1840,
        -16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fea627fd-6fed-4913-8297-566326e5df1d",
              "name": "opportunity",
              "type": "boolean",
              "value": "={{ $json.output.opportunity }}"
            },
            {
              "id": "e11d151c-63ea-4096-a95e-c2029d9b398b",
              "name": "reason",
              "type": "string",
              "value": "={{ $json.output.reason }}"
            },
            {
              "id": "8bcdfa3b-1b6e-4fa9-9276-9764b9d40391",
              "name": "trigger_sentence",
              "type": "string",
              "value": "={{ $json.output.trigger_sentence }}"
            },
            {
              "id": "75353e12-7795-420d-ac3e-2acbbe6c6fbe",
              "name": "suggested_comment",
              "type": "string",
              "value": "={{ $json.output.suggested_comment }}"
            },
            {
              "id": "be81a3ae-ebe0-48f2-b329-0f0e64141cb9",
              "name": "name",
              "type": "string",
              "value": "={{ $('Extract Post Data').item.json.name }}"
            },
            {
              "id": "05983218-c090-45e2-8d30-5d2be725b350",
              "name": "createdAt",
              "type": "string",
              "value": "={{ $('Extract Post Data').item.json.createdAt }}"
            },
            {
              "id": "74815fe9-f761-4496-913a-b757042a80b7",
              "name": "url",
              "type": "string",
              "value": "={{ $('Extract Post Data').item.json.url }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6546a6b7-d53e-40b8-ac21-1e90d65b3b13",
      "name": "Filter Opportunities To Comment",
      "type": "n8n-nodes-base.filter",
      "position": [
        2064,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2a0b06dd-f7c0-412e-916a-f8fe89b1f97e",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.opportunity }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "211d371b-1193-4920-b35e-e7f610df7cb1",
      "name": "Record Results",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2288,
        -16
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appImGQn0rh53oCPE",
          "cachedResultUrl": "https://airtable.com/appImGQn0rh53oCPE",
          "cachedResultName": "Skool comments"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblkB1UJ5dihXvDoi",
          "cachedResultUrl": "https://airtable.com/appImGQn0rh53oCPE/tblkB1UJ5dihXvDoi",
          "cachedResultName": "Table 1"
        },
        "columns": {
          "value": {
            "url": "={{ $json.url }}",
            "date": "={{ $now }}",
            "title": "={{ $json.name }}",
            "config": "=[\"{{ $('Extract Config').first().json.Name }}\"]",
            "reason": "={{ $json.reason }}",
            "trigger": "={{ $json.trigger_sentence }}",
            "suggested answer": "={{ $json.suggested_comment }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "dateTime",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "trigger",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "trigger",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "suggested answer",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "suggested answer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Select",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "not commented",
                  "value": "not commented"
                },
                {
                  "name": "commented",
                  "value": "commented"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Select",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "config",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "config",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "title"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "typecast": true
        },
        "operation": "upsert"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f884d6b6-d2a7-4645-aa76-8165aeb17331",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -288
      ],
      "parameters": {
        "width": 1072,
        "height": 432,
        "content": "## Get config\nGet config from airtable\ngroup it by url (the apify actor seems to have a bug and is only getting the first url if we pass it as an array)"
      },
      "typeVersion": 1
    },
    {
      "id": "b38546ec-218e-4cb6-9e58-19d4435c6aee",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        -288
      ],
      "parameters": {
        "color": 3,
        "width": 816,
        "height": 432,
        "content": "## Analyze posts with AI\nThis is dynamic based on the config criterias\n- does it worth commenting and why?\n- if yes create the comment"
      },
      "typeVersion": 1
    },
    {
      "id": "f7d2a5ab-41d3-4ce4-b0c7-06489b81c5b3",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -128,
        -16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 19
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c23eb77f-60e4-4f0e-b37d-19d1db708566",
      "name": "Split Out1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        768,
        -16
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "Skool URLs"
      },
      "typeVersion": 1
    },
    {
      "id": "a622f65e-ca43-4a1e-9fcd-5456b61485ca",
      "name": "Is Active?",
      "type": "n8n-nodes-base.filter",
      "position": [
        320,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "95a95eba-ab46-481c-8754-8c6c8b75df5a",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.active }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "80e966f3-06e9-47e3-9e72-e09e6923162e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        -528
      ],
      "parameters": {
        "color": 4,
        "content": "## Airtable tempplate\nhttps://airtable.com/appImGQn0rh53oCPE/shrqBY3WUtMxUZnYa"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Get Config": {
      "main": [
        [
          {
            "node": "Is Active?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Active?": {
      "main": [
        [
          {
            "node": "Extract Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out1": {
      "main": [
        [
          {
            "node": "Get Skool Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Config": {
      "main": [
        [
          {
            "node": "Split Out1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Record Results": {
      "main": [
        []
      ]
    },
    "Get Skool Posts": {
      "main": [
        [
          {
            "node": "Extract Post Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Post Data": {
      "main": [
        [
          {
            "node": "EvaluateOpportunities And Generate Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "EvaluateOpportunities And Generate Comments",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "EvaluateOpportunities And Generate Comments",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Filter Opportunities To Comment": {
      "main": [
        [
          {
            "node": "Record Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge AI Answers With Extracted Data": {
      "main": [
        [
          {
            "node": "Filter Opportunities To Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "EvaluateOpportunities And Generate Comments": {
      "main": [
        [
          {
            "node": "Merge AI Answers With Extracted Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}