{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automate LinkedIn Posts to Email Newsletter with Apify and GPT-4",
  "tags": [],
  "nodes": [
    {
      "id": "8a1122dd-fe22-482d-b1c9-e9d4f318f34e",
      "name": "Weekly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        272,
        -448
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4dab4d82-bf50-4378-b1c1-2dc926e0f6d3",
      "name": "Run an Actor and Get All LinkedIn Posts",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        720,
        -448
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_APIFY_ACTOR_ID"
        },
        "timeout": {},
        "operation": "Run actor and get dataset",
        "customBody": "={\n  \"usernames\": [\"your-linkedin-username\"],\n  \"maxItems\": 1,\n  \"maxResults\": 1\n}",
        "authentication": "apifyOAuth2Api"
      },
      "credentials": {
        "apifyOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "332c9b28-4cf4-43c9-8ba4-50648c647f54",
      "name": "Pulls the First Post",
      "type": "n8n-nodes-base.limit",
      "position": [
        288,
        -112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3f02e139-c101-4b90-82a7-3fd3c59874fe",
      "name": "Convert LinkedIn Post to Email Newsletter",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        288,
        240
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an expert email newsletter writer who specializes in converting social media content into engaging email formats. Your task is to transform LinkedIn posts into professional, well-formatted email newsletters that:\n\n- Maintain the core message and key insights from the original post\n- Adapt the tone to be more conversational and suitable for email\n- Add proper email structure (greeting, body, closing)\n- Include a clear subject line\n- Enhance readability with proper formatting\n- Add a call-to-action when appropriate\n\nKeep the newsletter concise, engaging, and optimized for email readers."
            },
            {
              "content": "=Convert the following LinkedIn post into an email newsletter format:\n\n{{ $json.linkedin_post }}\n\nPlease provide:\n1. **Subject Line**: An attention-grabbing subject line (50-60 characters)\n2. **Preview Text**: A short preview/preheader (40-50 characters)\n3. **Email Body**: The converted content with:\n   - A friendly greeting\n   - Well-structured paragraphs\n   - Bullet points where appropriate\n   - Do not provide a call to action\n   - A professional closing\n   - Always end with this signature:  \n      Best regards, \n      [Your Name]\n      [Your Company]\n\n\nFormat the output as structured text that's ready to send."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "44429f63-f9c0-4e93-9280-f94cede35a11",
      "name": "Convert Text to HTML Format",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        592,
        240
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an expert email HTML developer who specializes in creating clean, responsive email HTML code. Your task is to convert plain text email newsletter content into well-formatted HTML that:\n\n- Uses inline CSS styles for maximum email client compatibility\n- Creates a responsive layout that works on desktop and mobile\n- Follows email HTML best practices (tables for layout, inline styles)\n- Uses web-safe fonts and colors\n- Ensures proper spacing and readability\n- Works across major email clients (Gmail, Outlook, Apple Mail, etc.)\n\nOutput ONLY the HTML code without any explanations or markdown code blocks."
            },
            {
              "content": "=Convert the following email newsletter into HTML format:\n\n{{ $json.message.content }}\n\nRequirements:\n- Use a clean, professional design with a maximum width of 600px\n- Apply inline CSS styles to all elements\n- Use a readable font (Arial, Helvetica, or similar web-safe font)\n- Include proper spacing between sections\n- Make headings bold and slightly larger\n- Format any bullet points as proper HTML lists\n- Do not include a call-to-action link\n- Do not end the newsletter article with a call-to-action statement or question\n- Use a color scheme that's professional (you can use shades of blue/gray)\n- Add proper padding and margins for readability\n- Ensure proper white space padding on the the left and right side of the text.\n\nReturn ONLY the complete HTML code ready to be used in an email, starting with a complete HTML structure including <html>, <head>, and <body> tags."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "747b1eb6-6592-42d8-bf99-ce562d72ef25",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        288,
        560
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.message.content }}",
        "options": {},
        "subject": "Latest Newsletter Article"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a9d244de-137e-48b2-b9fa-95a64f9c540a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -224
      ],
      "parameters": {
        "color": 3,
        "width": 624,
        "height": 288,
        "content": "## LinkedIn Posts Filtering\n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/sticky-notes/)"
      },
      "typeVersion": 1
    },
    {
      "id": "3241f567-94fa-40b8-8e01-8272358a410e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        112
      ],
      "parameters": {
        "color": 5,
        "width": 624,
        "height": 304,
        "content": "## Post Conversion to Newsletter Article\n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/sticky-notes/)"
      },
      "typeVersion": 1
    },
    {
      "id": "e792ed75-554f-4eee-9b40-a16d99a545b7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -544
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 272,
        "content": "## LinkedIn Posts Ingestion\n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/sticky-notes/)"
      },
      "typeVersion": 1
    },
    {
      "id": "7ba0da38-a9db-47bc-9e85-26de604afd18",
      "name": "Variable Mapping",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        -112
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ad1ec8a7-a12c-4f81-8c6f-01152328ab40",
              "name": "linkedin_post",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5c19bf72-0993-4154-a37b-7eca6e3e80fd",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        464
      ],
      "parameters": {
        "color": 5,
        "width": 624,
        "height": 256,
        "content": "## Email Delivery\n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/sticky-notes/)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "Weekly Schedule": {
      "main": [
        [
          {
            "node": "Run an Actor and Get All LinkedIn Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variable Mapping": {
      "main": [
        [
          {
            "node": "Convert LinkedIn Post to Email Newsletter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pulls the First Post": {
      "main": [
        [
          {
            "node": "Variable Mapping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Text to HTML Format": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor and Get All LinkedIn Posts": {
      "main": [
        [
          {
            "node": "Pulls the First Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert LinkedIn Post to Email Newsletter": {
      "main": [
        [
          {
            "node": "Convert Text to HTML Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}