Automate Viral LinkedIn Posts with AI Research + Infographics using n8n

26 min build: form, Perplexity research, AI post, infographic via OpenAI image API, human review in Sheets, then auto-post to LinkedIn. Blueprint on Gumroad. Content marketing.

playbook
Last updated Nov 21, 2026

This article was originally posted on YouTube

One of the biggest struggles for founders and solopreneurs is consistent content creation. This n8n automation creates LinkedIn posts backed by research from Perplexity, with an infographic made by OpenAI's image model. You approve each post in a Google Sheet before it goes live.

How it works

Two workflows:

  1. Create: form → post writer agent (with Perplexity) → image prompter agent → image generation → Google Drive → Google Sheets.

  2. Publish: when you set the status to "Post to LinkedIn" in the sheet, the image is downloaded, the post is published and the sheet is updated.

It is a human-in-the-loop automation. You can edit the text in the sheet before posting.

Workflow 1: create the post

Step 1: form trigger

Add an n8n form trigger. Title: "Create LinkedIn research post". Add three required fields:

  • Topic (text)

  • Length (dropdown): short (around 80 words), medium (around 200 words), long (around 350 words)

  • Target audience (text)

Submit a test and pin the data, so the next steps are easier to build.

Step 2: post writer agent

  1. Add an AI agent and choose "Define below" for the prompt.

  2. Connect an OpenAI chat model. GPT 4.1 mini works fine. For credentials, create a secret key in the OpenAI platform under API keys.

  3. Put the main instructions in the system message (Add option → System message), not in the user message. I write prompts in Markdown, because headings keep the sections organized for the LLM.

What the system prompt says:

  • You are an agent that creates professional, educational and engaging LinkedIn posts.

  • Always begin with real-time research using the Perplexity tool.

  • Write in a professional tone, clear and easy to read, light on emojis (overusing emojis gives AI away), with relevant hashtags and a clear CTA.

  • Output only the final post text. No explanations or notes.

  • No direct citations or URLs in the post.

  • Example workflow: receive a topic, use the tool, format, create the post.

  • Add today's date, so the model doesn't assume an older year.

The user message is an expression with the form values: post topic, post length, target audience.

Step 3: Perplexity tool

Add an HTTP Request tool to the agent.

  1. In Perplexity, go to Account → API → API keys and create a key.

  2. In the Perplexity API reference, open the chat completions endpoint and copy the cURL example.

  3. In n8n, use "Import cURL" and paste it. The request is pre-filled.

  4. Replace the token with your API key. Rename the node "Perplexity tool".

  5. In the body, remove the system role, keep the user role, and use the Sonar Pro model. You don't need deep research here.

  6. Make the question dynamic. Switch the field to expression and use the $fromAI function with a key (prompt), a description ("prompt sent to Perplexity to research the user's requested topic") and the type string.

Test it. In the logs you see the agent's question, and Perplexity's answer with citations and search results.

Step 4: image prompter agent

Add a second AI agent, also with GPT 4.1 mini. No tool needed.

  • System message: you are an AI agent that turns LinkedIn posts into visual prompt descriptions. Read and analyze the post, then create a clear, compelling graphic prompt for a text-to-image generator. Include today's date.

  • User message: the output of the post writer.

Step 5: generate the image

Use the OpenAI "Generate an image" node with the prompt from step 4. It takes 30 seconds to 1 minute. I tried high quality and saw little difference, so I went back to medium.

Step 6: upload to Google Drive and share

  1. Google Drive → Upload a file, binary field data. Creating a Google Drive credential goes through Google Cloud (client ID and secret). It's a lengthy process, look up a tutorial.

  2. Google Drive → Share file: map the file ID, role reader, type anyone. Without this, the later download may fail because the file is private.

Step 7: append a row in Google Sheets

Create a sheet with these headers: topic, content, image URL, file ID, status, date posted. Make status a dropdown with two options: "Post to LinkedIn" and "Posted".

In n8n, add Google Sheets → Append row and map:

  • Topic: from the form

  • Content: the post writer output

  • Image URL: the web view link from Drive

  • File ID: from Drive

  • Status and date posted: leave blank

Unpin everything and run the workflow. It takes up to about 2 minutes.

Workflow 2: publish from the sheet

Step 1: trigger

Google Sheets trigger → "On row updated", polling every minute. Add the option to watch only the status column.

Step 2: download the image

Google Drive → Download file, by URL or by ID.

Step 3: create the LinkedIn post

LinkedIn → Create a post.

  • Connect your account. Important: turn off "organization support", otherwise it won't work.

  • Post as person, pick your account.

  • Text: the content column from the sheet.

  • Media category: image. Input binary field: data.

Step 4: update the sheet

Google Sheets → Update row. Match on file ID (it is unique every time). Set status to "Posted" (the text must match the dropdown exactly) and date posted to now.

Result

Set a row to "Post to LinkedIn" and within a minute the post is live with its infographic, and the row shows "Posted". You can change the form, for example other lengths. The blueprints are linked in the video description. You only need to replace the credentials and API keys.

Comments

Login to leave a comment