{
  "name": "linkedinGhostWritter",
  "nodes": [
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "15aeac4c-d92f-4d90-98e1-695cd53570f5",
              "name": "linkedinURL",
              "value": "={{ $json.body.linkedinUrl }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        80,
        420
      ],
      "id": "98a0e543-3da0-4272-8701-6c64e8483da4",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/dev_fusion~linkedin-profile-scraper/runs?token=apify_api_5ytrhHkfUpb7wvx83mlKBigCpwflBC2T5EdB",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "=profileUrls",
              "value": "={{ [$('Webhook').item.json.body.linkedinUrl] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        320,
        420
      ],
      "id": "d6cd6daa-04d6-44b2-9e3e-d7c6fcf13789",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=\ud83d\udcc4 The following is the user's LinkedIn profile information:\n\n\ud83d\udc64 **Headline**:  {{ $('Scrapper').item.json.headline  ?? '' }}\n\ud83e\uddfe **About**: {{ $('Scrapper').item.json.about?.slice(0, 700) ?? '' }}\n\n\ud83d\udcda Below are some of the user\u2019s past LinkedIn posts. Analyze their tone, storytelling style, emoji usage, and structure.\n\n{{ $json.combinedPostText.slice(0, 2000) ?? '' }}\n\n\n---\n\n\u270d\ufe0f Now, based on this tone and voice, generate a **new LinkedIn post**.\n\n\ud83c\udfaf **Topic**: {{ $('Webhook').item.json.body.topic  ?? '' }}\n\ud83e\udde0 **Perspective**:  {{ $('Webhook').item.json.body.perspective  ?? ''}}\n\ud83d\udcc2 **Category**: {{ $('Webhook').item.json.body.category  ?? '' }}\n\n\ud83d\udccc Output Guidelines:\n- Start with a compelling hook line (use an emoji)\n- Follow a story-driven structure (personal touch + examples)\n- Use emojis that reflect the tone and add clarity\n- Make it sound authentic, like the previous posts\n- Reflect the user\u2019s experience, mindset, and domain knowledge\n- End with a reflective question or a powerful takeaway\n- Include **3\u20135 relevant and creative hashtags**\n",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        2120,
        240
      ],
      "id": "990090a2-4697-4f3d-b5e2-057b811a0c3d",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": "llama-3.3-70b-versatile",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        2120,
        500
      ],
      "id": "4f35921e-cf6e-4c8d-a48e-c53856839a2f",
      "name": "Groq Chat Model",
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "trial-session-run"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        2240,
        640
      ],
      "id": "55b9cd43-efa4-4b52-9cf7-594058f6ed92",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "jsCode": "const updates = $input.first().json.updates || [];\nlet combinedText = \"\";\n\nfor (let i = 0; i < updates.length; i++) {\n  if (updates[i].postText) {\n    combinedText += `\ud83d\udcdd Post ${i + 1}:\\n${updates[i].postText}\\n\\n`;\n  }\n}\n\nreturn [\n  {\n    json: {\n      combinedPostText: combinedText.trim()\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1840,
        240
      ],
      "id": "6583b1af-a8a1-4c55-8c8e-20d1c1fbe06f",
      "name": "Code"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "d2d4342f-c128-41c0-8c19-840855d034fc",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -480,
        20
      ],
      "id": "c8c2c507-4440-48a9-935c-25e7eeba1a28",
      "name": "Webhook"
    },
    {
      "parameters": {
        "amount": 15
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1220,
        240
      ],
      "id": "0aa99387-4f50-4044-9d7b-fdf47025aab5",
      "name": "Wait"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "20535b95-5f6f-40df-a650-ea7c1bc3abbb",
              "name": "runId",
              "value": "={{ $json.data.id }}",
              "type": "string"
            },
            {
              "id": "38dbf1a3-44b2-4b53-a0e2-7c3a94240c55",
              "name": "datasetId",
              "value": "={{ $json.data.defaultDatasetId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        600,
        420
      ],
      "id": "15c3d563-3a02-4e86-b483-186f1093a95c",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "amount": 9
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        840,
        420
      ],
      "id": "7098d640-a5ec-4aba-8d6d-eeaa34de0e24",
      "name": "Wait1"
    },
    {
      "parameters": {
        "url": "=https://api.apify.com/v2/actor-runs/{{ $json.runId }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1020,
        240
      ],
      "id": "294677ec-facc-4b6b-9b6f-9bdd7986632c",
      "name": "status"
    },
    {
      "parameters": {
        "url": "=https://api.apify.com/v2/datasets/{{ $json.data.defaultDatasetId }}/items?format=json",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1520,
        240
      ],
      "id": "8bdb5227-5907-485d-b0c9-f62a2841a4fc",
      "name": "Scrapper"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"message\": $json.finalPost} }}",
        "options": {
          "responseCode": 200
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        2660,
        240
      ],
      "id": "e2e0080a-d5b0-4aac-93c9-c74a0fd6f3f7",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6e7bbf94-8492-4c9b-bd49-8bcb0401eeff",
              "name": "finalPost",
              "value": "={{ $('AI Agent').item.json.output ?? '' }}\n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2440,
        240
      ],
      "id": "d93228cd-1df2-471b-8feb-cdb0fd7adb48",
      "name": "Edit Fields3"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "6589af5f-ba5e-47be-8217-bb9571e9d7a9",
              "leftValue": "={{ $('status').item.json.data.status }}",
              "rightValue": "SUCCEEDED",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1400,
        440
      ],
      "id": "81de96c3-68b9-4ee6-b65e-39dbfbdc770b",
      "name": "If"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d24e62d7-1d4b-489d-92bd-5b5b9fa66ebf",
              "leftValue": "={{ $json.body.mode }}",
              "rightValue": "manual",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -80,
        20
      ],
      "id": "d82f46df-fff8-485d-b6c1-a4f30c19abcd",
      "name": "If1"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=\ud83d\udcc4 Below are multiple LinkedIn posts written by the user. These reflect their authentic voice, tone, structure, and use of emojis.\n\n{{ $('Webhook').item.json.body.postsArray.join('\\n\\n---\\n\\n') ?? '' }}\n\n\ud83e\udde0 Analyze the tone, sentence flow, storytelling style, emoji usage, and structure. Understand how the user expresses their thoughts, emotions, and expertise across posts.\n\n---\n\n\u270d\ufe0f Now, based on this voice and style, generate a **new LinkedIn post**.\n\n\ud83c\udfaf **Topic**: {{ $('Webhook').item.json.body.topic ?? '' }}\n\ud83d\udcac **Perspective**: {{ $('Webhook').item.json.body.perspective ?? '' }}\n\ud83d\udcc2 **Category**: {{ $('Webhook').item.json.body.category ?? '' }}\n\n\ud83d\udccc Output Guidelines:\n- Start with a compelling hook line (use an emoji)\n- Follow a personal, story-driven structure (authenticity matters)\n- Use emojis that match the tone and enhance clarity\n- Imitate the sentence rhythm, paragraph style, and word choice from the user\u2019s past posts\n- Reflect the user\u2019s mindset and domain understanding\n- End with a thought-provoking line, question, or insight\n- Add **3\u20135 creative and relevant hashtags**\n",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        260,
        -220
      ],
      "id": "c0ec6e82-6c16-4a10-b7f3-b9fee0529a21",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "model": "llama-3.3-70b-versatile",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        260,
        20
      ],
      "id": "c2889348-a385-486f-82bc-79e40a569ea2",
      "name": "Groq Chat Model1",
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "trail-session-run"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        380,
        160
      ],
      "id": "6911feba-9b1d-4360-b731-9f1052c04cb0",
      "name": "Simple Memory1"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"message\": $json.output} }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        660,
        -220
      ],
      "id": "15ac9e53-5d8a-49c1-90ce-d63c4a0f4a72",
      "name": "Respond to Webhook1"
    }
  ],
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "status": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrapper": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Scrapper",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4f1c2da0-0650-4f13-9a48-82f4bc81c979",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "v61JLeHLKOQMgbNz",
  "tags": []
}