{
  "nodes": [
    {
      "parameters": {
        "httpRequestMethod": "POST",
        "options": {}
      },
      "id": "c8d676c7-7813-4efb-a3bb-730afb3ff692",
      "name": "Facebook Graph API1",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        64,
        144
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "authentication": "communityManagement",
        "person": "[CONFIGURE_YOUR_LINKEDIN_PERSON_ID]",
        "text": "={{ $json['choices[0].message.content'] }}",
        "additionalFields": {}
      },
      "id": "6b85f990-980a-4456-a4e7-265ce9860ddf",
      "name": "LinkedIn1",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        64,
        352
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "[YOUR_GOOGLE_SHEETS_DOCUMENT_ID]",
          "cachedResultUrl": "[YOUR_GOOGLE_SHEETS_URL]",
          "cachedResultName": "LinkedIn Automation"
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "[YOUR_GOOGLE_SHEETS_URL]",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "value": {
            "Topic": "={{ $('Choosing Topic').item.json.message.content }}",
            "Status": "Posted",
            "AI Output": "={{ $json['choices[0].message.content'] }}",
            "Date Posted": "={{ $('Schedule Trigger').item.json.timestamp }}"
          },
          "schema": [
            {
              "id": "Topic",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Topic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AI Output",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AI Output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date Posted",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date Posted",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Topic"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "2e5ce899-1c17-4530-9902-5c71501e8848",
      "name": "Google Sheets2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        336,
        352
      ],
      "typeVersion": 4.5
    },
    {
      "parameters": {
        "fieldToSplitOut": "choices[0].message.content",
        "options": {}
      },
      "id": "a6f7dcb6-fdfe-4621-9b9c-a067b9d4c994",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -160,
        352
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 6
            },
            {
              "triggerAtHour": 18
            }
          ]
        }
      },
      "id": "2a50d77b-7283-4f08-8e1c-d0f8317fdc99",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1856,
        352
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.perplexity.ai/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"sonar-pro\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"Act as a skilled editor revising AI-generated text to sound authentically human. Follow these rules:\\n\\n1. Punctuation Adjustments\\n   - Replace em dashes, semicolons, or rephrase sentences where appropriate.\\n   - Avoid semicolons in casual contexts; use periods or conjunctions (e.g., 'and,' 'but').\\n   - Remove mid-sentence ellipses unless mimicking deliberate hesitation.\\n   - Limit parenthetical asides; integrate explanations into the main sentence.\\n   - Use colons sparingly.\\n\\n2. Language\\n   - Replace hedging phrases with direct statements.\\n   - Avoid stock transitions.\\n   - Vary repetitive terms.\\n   - Use contractions in informal contexts.\\n   - Replace overly formal words with simpler alternatives.\\n\\n3. Style\\n   - Prioritize concise, varied sentence lengths.\\n   - Allow minor imperfections.\\n   - Maintain the core message but adjust tone to match the audience.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"You are a researcher and expert copywriter in a business development team of an AI Automation Agency. Generate exactly one LinkedIn post that adheres to LinkedIn's API formatting guidelines and is easy for humans to read. Follow these rules:\\n\\nStructure:\\n1. Hook: Start with a bold opening line using Unicode characters (e.g., \\\"\ud835\udc01\ud835\udc0e\ud835\udc0b\ud835\udc03 \ud835\udc12\ud835\udc13\ud835\udc00\ud835\udc13\ud835\udc04\ud835\udc0c\ud835\udc04\ud835\udc0d\ud835\udc13\\\").\\n2. Body: Use short paragraphs (1-3 sentences) separated by \\\\n\\\\n.\\n3. Use bullet points (\u2022) for key features or highlights.\\n4. End with a clear call-to-action (e.g., \\\"Comment below with your thoughts!\\\").\\n\\nFormatting Requirements:\\n- Remove all numeric citation brackets like [2], [3], [4] from the text.\\n- Instead of citation brackets, if needed, add a brief phrase like \\\"according to Google I/O 2025\\\" or \\\"as reported by DeepMind\\\" naturally within the sentence.\\n- No Markdown or rich text formatting.\\n- Use Unicode characters or emojis for emphasis (e.g., \u2605, \ud83d\ude80).\\n- Include up to 3 relevant hashtags at the end (e.g., #AI #Automation).\\n- For URLs or references, use placeholders like [Link] instead of raw URLs.\\n- If mentioning users or companies, use official LinkedIn URN format (e.g., \\\"urn:li:organization:123456\\\").\\n\\nContent Rules:\\n- Max 1,200 characters.\\n- Avoid promotional language.\\n- Include one statistical claim or industry insight.\\n- Add one personal anecdote or professional observation.\\n\\nReturn the post as plain text without additional commentary.\\n\\nInput: {{ $json.message.content }}\"\n    }\n  ]\n}\n",
        "options": {}
      },
      "id": "76bc05f9-76d0-4d91-b29e-dbabf1dc640f",
      "name": "Research Topic- Perplexity",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -528,
        352
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={\n  \"most-trending\": {\n\n    \"#1\": { \n\n      \"query\":\"{{ $json.related_queries.rising[0].query }}\",\n      \"score\":\"{{ $json.related_queries.rising[0].extracted_value }}\"\n\n    },\n\n\n    \"#2\": { \n\n      \"query\":\"{{ $json.related_queries.rising[1].query }}\",\n      \"score\":\"{{ $json.related_queries.rising[1].extracted_value }}\"\n\n    }\n  }\n}",
        "options": {}
      },
      "id": "ee0d8334-8680-4c9b-96f4-98f5d5986a96",
      "name": "2 Most Trending",
      "type": "n8n-nodes-base.set",
      "position": [
        -1424,
        352
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "jsCode": "// Get the top array from your JSON\nconst topItems = $('Google Trends').first().json.related_queries.top;\n\n// Filter the items to only include those with extracted_value > 30\nconst filtered = topItems.filter(item => item.extracted_value > 30);\n\n// Map the filtered items to their query values and join them with commas\nconst resultString = filtered.map(item => item.query).join(', ');\n\n// Return the result in a new JSON property\nreturn [{ json: { result: resultString } }];\n"
      },
      "id": "3f3ec3da-9838-4523-ac9b-c3ea1b42b697",
      "name": "High search volume keywords",
      "type": "n8n-nodes-base.code",
      "position": [
        -1200,
        352
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-3.5-turbo",
          "cachedResultName": "GPT-3.5-TURBO"
        },
        "messages": {
          "values": [
            {
              "content": "=You are part of a team that creates world class blog posts. Your job is to choose the topic for each blog post. \n\nThe blog posts are posted on the website of a [COMPANY NAME + DESCRIPTION + PRODUCTS + TARGET MARKET]. The blog posts are mainly posted as part of an SEO campaign to get [YOUR_COMPANY] to rank high for its products and services.\n\nIn this instance, you are given a list of 2 keywords which have been trending the most on Google news search over the past few days. \n\nYour job is to pick one which you think would make for the most relevant blog post with the best SEO outcomes for the client. \n\nThe keywords have two attributes: \n\n1. query: This attribute determines the search query that users have been searching for which is trending. \n\n2. value: This attribute determines what percentage increase the keyword has seen compared to previous periods (i.e. the increase in search volume). \n\nYou must choose one out of the taking into consideration both the relevance of the keyword for [YOUR_COMPANY]'s SEO efforts and the comparative trendiness determined by the value attribute. \n\nOutput the keyword you decided to post a blog on and nothing else. Don't explain your reasoning. Just output the keyword. \n\nThis instance: \n\nKeyword 1:\n{{ $('2 Most Trending').item.json['most-trending']['#1'].toJsonString() }} \n\nKeyword2: \n{{ $('2 Most Trending').item.json['most-trending']['#2'].toJsonString() }} "
            }
          ]
        },
        "options": {}
      },
      "id": "e77d124f-46cd-4e1a-aba1-033ca7da3055",
      "name": "Choosing Topic",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -960,
        352
      ],
      "typeVersion": 1.8
    },
    {
      "parameters": {
        "content": "## Find Trend\n\n",
        "height": 240,
        "width": 400
      },
      "id": "d31ace32-8fa4-4c6c-ac2f-02b53913bb56",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        272
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## High Volume Keywords\n\n",
        "height": 240,
        "width": 200
      },
      "id": "cb3c24d7-1fc5-4727-8283-7c3b708ef7ef",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        272
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## Choosing Blog Topic\n\n\n",
        "height": 240,
        "width": 340
      },
      "id": "a047b33b-91d0-4a82-afe9-866a71f637e6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        272
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## Research\n\n\n",
        "height": 240,
        "width": 600
      },
      "id": "6ae6f985-7354-4670-ad90-ec23b46837bb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        272
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "url": "https://serpapi.com/search",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "=ai agents"
            },
            {
              "name": "geo",
              "value": "US"
            },
            {
              "name": "hl",
              "value": "en"
            },
            {
              "name": "date",
              "value": "={{ $now.minus({ days: 3 }).format('yyyy-MM-dd') }} {{ $now.format('yyyy-MM-dd') }}"
            },
            {
              "name": "data_type",
              "value": "RELATED_QUERIES"
            },
            {
              "name": "engine",
              "value": "google_trends"
            },
            {
              "name": "api_key",
              "value": "[YOUR_SERPAPI_KEY]"
            }
          ]
        },
        "options": {}
      },
      "id": "555a961a-d081-45ff-8404-7db87f1f6fd4",
      "name": "Google Trends",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1648,
        352
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "amount": 10
      },
      "id": "b0872dff-b962-4075-8434-d9667ec8df70",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        -336,
        352
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "content": "## Multi Social Media Posting",
        "height": 800
      },
      "id": "a1f90585-2932-43a9-8d17-d5b50f0f5e61",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## Status update",
        "height": 260
      },
      "id": "828a99ca-c937-4a96-bad4-0b70fd838e70",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        272
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "resource": "carousel",
        "carouselMedia": {
          "mediaItem": []
        }
      },
      "type": "@mookielianhd/n8n-nodes-instagram.instagram",
      "typeVersion": 1,
      "position": [
        64,
        576
      ],
      "id": "502a3d1f-4db8-4a4f-9085-feac33e83534",
      "name": "Publish"
    }
  ],
  "connections": {
    "LinkedIn1": {
      "main": [
        [
          {
            "node": "Google Sheets2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Facebook Graph API1",
            "type": "main",
            "index": 0
          },
          {
            "node": "LinkedIn1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Publish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Google Trends",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Topic- Perplexity": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2 Most Trending": {
      "main": [
        [
          {
            "node": "High search volume keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "High search volume keywords": {
      "main": [
        [
          {
            "node": "Choosing Topic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Choosing Topic": {
      "main": [
        [
          {
            "node": "Research Topic- Perplexity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Trends": {
      "main": [
        [
          {
            "node": "2 Most Trending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}