{
  "id": "JYYtngJQ9CKSOmgS",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Generate Daily Twitter & LinkedIn Posts from AI & Blockchain News with SerpAPI, Groq and Pollinations",
  "tags": [],
  "nodes": [
    {
      "id": "a06d9614-1ac6-40bf-81c0-3c607eca6b4f",
      "name": "Test Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -800,
        192
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e6cd5e7e-aec1-43e5-8085-12547708ffe6",
      "name": "Fetch AI & Blockchain News",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -576,
        96
      ],
      "parameters": {
        "url": "https://serpapi.com/search",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "engine",
              "value": "google"
            },
            {
              "name": "q",
              "value": "AI OR \"artificial intelligence\" OR blockchain OR crypto"
            },
            {
              "name": "tbm",
              "value": "nws"
            },
            {
              "name": "tbs",
              "value": "qdr:d"
            },
            {
              "name": "num",
              "value": "20"
            },
            {
              "name": "gl",
              "value": "us"
            },
            {
              "name": "hl",
              "value": "en"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.4
    },
    {
      "id": "a61624b3-5223-43fa-8f5c-2aaac2b8834d",
      "name": "Run Daily at 8 AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -800,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f386863d-ddaf-4a84-9f86-7993e6308dd5",
      "name": "Build News Digest",
      "type": "n8n-nodes-base.code",
      "position": [
        -352,
        96
      ],
      "parameters": {
        "jsCode": "const news = $input.first().json.news_results || [];\nconst digest = news\n  .map((n, i) => `${i + 1}. ${n.title} (${n.source}, ${n.date})\\n   ${n.snippet}\\n   ${n.link}`)\n  .join('\\n\\n');\nreturn [{ json: { digest, count: news.length } }];"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "68203905-220a-4212-a732-c69fa7ef7266",
      "name": "Check News Found",
      "type": "n8n-nodes-base.if",
      "position": [
        -128,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.count }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "0bd5c9f8-7299-4fc7-a01e-26b8acc07b98",
      "name": "Write Social Media Posts",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        160,
        -64
      ],
      "parameters": {
        "text": "=Here are today's top AI & blockchain headlines:\n\n{{ $json.digest }}\n\nCreate:\n1. A Twitter/X post (max 280 characters, punchy, include 2-3 relevant hashtags)\n2. A LinkedIn post (professional tone, 150-300 words, storytelling format, end with a question)\n\nReturn as JSON with keys: twitter, linkedin",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are a social media manager who writes punchy, high-engagement posts about AI and blockchain news. Output only the posts, nothing else."
            }
          ]
        },
        "promptType": "define"
      },
      "retryOnFail": true,
      "typeVersion": 1.9,
      "waitBetweenTries": 3000
    },
    {
      "id": "264a6123-be71-4290-a451-a5f0da3bfd3f",
      "name": "Groq Llama 3.3 Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        256,
        320
      ],
      "parameters": {
        "model": "llama-3.3-70b-versatile",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "941f09a4-db8b-4ae9-a5c8-227eded04829",
      "name": "Parse Generated Posts",
      "type": "n8n-nodes-base.code",
      "position": [
        384,
        -64
      ],
      "parameters": {
        "jsCode": "const raw = $json.text;\nconst parsed = JSON.parse(raw.substring(raw.indexOf(\"{\"), raw.lastIndexOf(\"}\") + 1));\nreturn [{ json: { twitter: parsed.twitter, linkedin: parsed.linkedin } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "739a4930-ff26-46ab-9e0d-fd8de00471b4",
      "name": "Generate Image with Pollinations",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        608,
        -64
      ],
      "parameters": {
        "url": "=https://gen.pollinations.ai/image/{{ encodeURIComponent('Professional, eye-catching social media image about: ' + $json.twitter + '. Modern, clean, business style. No text.') }}?model=flux&width=1024&height=1024&nologo=true",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "retryOnFail": true,
      "typeVersion": 4.4,
      "waitBetweenTries": 3000
    },
    {
      "id": "3cc3aaba-e5d9-4ae2-adfb-6bbd3aa87819",
      "name": "Upload Image to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueErrorOutput",
      "position": [
        832,
        -128
      ],
      "parameters": {
        "name": "={{ $now.toFormat('yyyyLLdd-HHmmss') }}.jpeg",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 3,
      "waitBetweenTries": 3000
    },
    {
      "id": "2a33c952-2912-4d40-bf68-2db204d78bfa",
      "name": "Make Image Public",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueErrorOutput",
      "position": [
        1056,
        -192
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Upload Image to Google Drive').item.json.id }}"
        },
        "options": {},
        "operation": "share",
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 3,
      "waitBetweenTries": 3000
    },
    {
      "id": "481aa384-da73-404b-a5f6-34a9b536e46a",
      "name": "Build Public Image URL",
      "type": "n8n-nodes-base.set",
      "onError": "continueErrorOutput",
      "position": [
        1280,
        -272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "image-url",
              "name": "imageUrl",
              "type": "string",
              "value": "=https://drive.google.com/uc?export=view&id={{ $('Upload Image to Google Drive').item.json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0013dd81-a9fb-4474-b6ea-401b0ed6a930",
      "name": "Save Posts to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1504,
        -320
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.7,
      "waitBetweenTries": 3000
    },
    {
      "id": "df1bd725-3b7a-475d-a065-0d877459d0fd",
      "name": "Log Success",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1728,
        -320
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5619b319-279b-46ad-b253-efac6ef2cdb8",
      "name": "Notify Slack of New Post",
      "type": "n8n-nodes-base.slack",
      "position": [
        1952,
        -320
      ],
      "parameters": {
        "text": "=:white_check_mark: *New Post Generated*\n\n*Trend:* {{ $('Fetch AI & Blockchain News').item.json.news_results[0].title }}\n*Time:* {{ $now.toFormat('yyyy-MM-dd HH:mm') }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "2870f786-ae70-4c72-8c02-de89b1c39000",
      "name": "Stop: Image Failed",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        1504,
        48
      ],
      "parameters": {
        "errorMessage": "Image was not generated"
      },
      "typeVersion": 1
    },
    {
      "id": "d5415b6b-c67e-443b-8511-9097f5d77a5b",
      "name": "Stop: No News Found",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        96,
        320
      ],
      "parameters": {
        "errorMessage": "No trends returned from SerpAPI"
      },
      "typeVersion": 1
    },
    {
      "id": "8b4d5eeb-93a0-4485-b4e9-4f2f9e67a61c",
      "name": "Sticky Note 0b7f88bb",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        -400
      ],
      "parameters": {
        "width": 480,
        "height": 740,
        "content": "## \ud83d\udcf0 Daily AI & Blockchain Trend Research + Social Posts\n\n**Who's it for:** Content creators, marketers, and founders who want a steady pipeline of ready-to-publish social content about AI and blockchain without manual research.\n\n**What it does:** Every morning it pulls the day's top AI & blockchain headlines from Google News (via SerpAPI), has Groq's Llama 3.3 write a Twitter/X post and a LinkedIn post, generates a matching image with Pollinations.ai, stores everything in Google Sheets for review, and pings you on Slack.\n\n**How it works:**\n1. Schedule Trigger fires daily at 8 AM (or run manually to test)\n2. SerpAPI fetches the last 24h of news headlines\n3. A Code node builds a numbered digest; an IF node stops with an error if no news was found\n4. Llama 3.3 70B writes a Twitter post + LinkedIn post as JSON\n5. Pollinations.ai generates a 1024x1024 image from the Twitter post\n6. The image is uploaded to Google Drive and made public\n7. Posts + image URL are appended to a Google Sheet ('content' tab) and a run log ('logs' tab)\n8. Slack gets a success notification\n\n**How to use:** Run manually once to verify each step, then activate. Review generated posts in the Sheet before publishing them."
      },
      "typeVersion": 1
    },
    {
      "id": "9bf5b088-b97f-44ba-adc8-943b1483e36e",
      "name": "Sticky Note dfe1bd3f",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        400
      ],
      "parameters": {
        "color": 4,
        "width": 480,
        "height": 620,
        "content": "### \u2699\ufe0f Setup (\u224810 min)\n\n1. **SerpAPI** \u2014 free key at serpapi.com. Create an n8n 'Query Auth' credential: name `api_key`, value = your key\n2. **Groq** \u2014 free key at console.groq.com, add a Groq credential\n3. **Pollinations** \u2014 add a Bearer Auth credential (get a token at auth.pollinations.ai; anonymous tier also works)\n4. **Google Drive** \u2014 connect OAuth2 and pick a destination folder in 'Upload Image to Google Drive'\n5. **Google Sheets** \u2014 create a spreadsheet with two tabs:\n   - Tab 1 columns: Date, Content Idea, Twitter Post, Linkedin Post, Image URL, Status, Notes\n   - Tab 2 (logs) columns: Timestamp, Status, Trend, Error, Execution Url\n   Then pick the document + tabs in both Sheets nodes\n6. **Slack** \u2014 connect a credential and pick your channel\n\n**Customize:**\n- Change the news topic by editing the `q` query parameter in 'Fetch AI & Blockchain News'\n- Adjust tone/format of posts in 'Write Social Media Posts'\n- Errors anywhere in the image pipeline route to 'Stop: Image Failed' so failed runs are visible"
      },
      "typeVersion": 1
    },
    {
      "id": "32123f18-9413-42a7-9714-c7a21dce582d",
      "name": "Sticky Note f5510537",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 748,
        "height": 200,
        "content": "### 1\ufe0f\u20e3 Research: fetch & digest the news"
      },
      "typeVersion": 1
    },
    {
      "id": "2d018616-84fb-4c81-b043-a38b8a0f956e",
      "name": "Sticky Note 6f0e6d49",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 524,
        "height": 200,
        "content": "### 2\ufe0f\u20e3 AI content: write the posts"
      },
      "typeVersion": 1
    },
    {
      "id": "1ec19965-d39c-474b-ad8d-18c33c8ed54f",
      "name": "Sticky Note e17bab30",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -320
      ],
      "parameters": {
        "color": 7,
        "width": 972,
        "height": 408,
        "content": "### 3\ufe0f\u20e3 Image: generate, upload, publish"
      },
      "typeVersion": 1
    },
    {
      "id": "6d5d3951-118d-45ee-a3f3-dfc3c1d15ab2",
      "name": "Sticky Note d9426534",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        -368
      ],
      "parameters": {
        "color": 7,
        "width": 748,
        "height": 200,
        "content": "### 4\ufe0f\u20e3 Save & notify"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "e08f1605-55dd-462f-b383-c142d277d605",
  "nodeGroups": [],
  "connections": {
    "Log Success": {
      "main": [
        [
          {
            "node": "Notify Slack of New Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Manually": {
      "main": [
        [
          {
            "node": "Fetch AI & Blockchain News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check News Found": {
      "main": [
        [
          {
            "node": "Write Social Media Posts",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: No News Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build News Digest": {
      "main": [
        [
          {
            "node": "Check News Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Make Image Public": {
      "main": [
        [
          {
            "node": "Build Public Image URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: Image Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Daily at 8 AM": {
      "main": [
        [
          {
            "node": "Fetch AI & Blockchain News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Llama 3.3 Model": {
      "ai_languageModel": [
        [
          {
            "node": "Write Social Media Posts",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse Generated Posts": {
      "main": [
        [
          {
            "node": "Generate Image with Pollinations",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Public Image URL": {
      "main": [
        [
          {
            "node": "Save Posts to Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: Image Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Social Media Posts": {
      "main": [
        [
          {
            "node": "Parse Generated Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch AI & Blockchain News": {
      "main": [
        [
          {
            "node": "Build News Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Posts to Google Sheets": {
      "main": [
        [
          {
            "node": "Log Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image to Google Drive": {
      "main": [
        [
          {
            "node": "Make Image Public",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: Image Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image with Pollinations": {
      "main": [
        [
          {
            "node": "Upload Image to Google Drive",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: Image Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}