How to Automate Your Social Media Posting with n8n and the OpenAI API in 2026 ⏱️ 8 min read

Posting consistently to social media is one of those tasks that feels easy until it eats your entire morning. The setup I’m describing here took about two hours to build and now runs on a $6/month VPS with zero ongoing intervention: n8n pulls content ideas from a spreadsheet, sends them to OpenAI for drafting, formats them per platform, and schedules the posts. Here’s exactly how to replicate it.

What You’re Building

The pipeline has four stages:

  1. Source: A Google Sheet with topic seeds (one-line ideas, links, or keywords)
  2. Generate: n8n calls the OpenAI API to turn each seed into platform-specific copy
  3. Schedule: Posts queue into Buffer or are sent directly via platform APIs
  4. Log: Results write back to the sheet so you can track what ran

Total cost: n8n self-hosted is free, OpenAI API runs roughly $0.002–0.005 per post using GPT-4o mini, Buffer’s free tier handles 3 channels with 10 scheduled posts each. For 30 posts/week, you’re looking at under $1/month in API costs.

Setting Up n8n

The fastest path is Docker on a VPS. On a $6/month Hetzner or DigitalOcean instance:

docker run -d   --name n8n   -p 5678:5678   -v ~/.n8n:/home/node/.n8n   -e N8N_BASIC_AUTH_ACTIVE=true   -e N8N_BASIC_AUTH_USER=admin   -e N8N_BASIC_AUTH_PASSWORD=yourpassword   n8nio/n8n

Add a Caddy or nginx reverse proxy with SSL and you have a production-ready n8n instance in under 20 minutes. If you’d rather skip server management, n8n Cloud starts at $20/month — worth it if your time is the constraint.

Once n8n is running, add your credentials: OpenAI API key under “Credentials → OpenAI”, Google Sheets OAuth under “Credentials → Google Sheets”, and Buffer API token if you’re routing through Buffer.

Building the Workflow

The core workflow in n8n uses five nodes:

Node 1 — Schedule Trigger: Set to run daily at 9 AM. Under “Cron Expression,” use 0 9 * * *. This fires the workflow once per day and processes that day’s batch of topics.

Node 2 — Google Sheets (Read): Connect to your sheet and filter rows where the “Status” column equals “pending.” This gives you only unprocessed topics. Set “Return All” to false and limit to 5 rows — you don’t want to blast 50 posts in one run.

Node 3 — OpenAI (Chat): Use the “Message a Model” operation. Model: gpt-4o-mini (fast, cheap, good enough for social copy). Prompt template:

You are a social media writer for a tech-focused account. 
Given this topic: "{{$json["topic"]}}"

Write:
1. A Twitter/X post (max 240 chars, no hashtags, punchy)
2. A LinkedIn post (150-200 words, professional but not stiff, one insight)
3. A short caption for Instagram (2-3 sentences + 5 relevant hashtags)

Return as JSON with keys: twitter, linkedin, instagram

Set temperature to 0.7 — lower gives bland copy, higher gets weird.

Node 4 — Code Node (Parse): OpenAI returns a string. Parse it:

const response = JSON.parse($input.first().json.message.content);
return [{ json: response }];

Node 5 — HTTP Request (Buffer API): POST to https://api.bufferapp.com/1/updates/create.json with your profile IDs and the parsed post text. Run this three times — once per platform — using n8n’s “Loop Over Items” or three separate HTTP Request nodes.

Handling the Google Sheet Feedback Loop

After posting, update the source row to prevent re-processing. Add a final Google Sheets node that sets the “Status” column to “published” and writes the post IDs to a “Results” column. This gives you a running log of what went out, when, and via which platform.

The sheet structure that works well:

  • Column A: Topic (your seed idea)
  • Column B: Status (pending / published / skipped)
  • Column C: Scheduled Date
  • Column D: Twitter post (written back by n8n)
  • Column E: LinkedIn post
  • Column F: Buffer post IDs

Improving Quality Over Time

The first week of output will be mediocre — that’s normal. The prompt is the main lever. A few changes that meaningfully improved my results:

  • Add 2-3 examples of good posts directly in the system prompt (“Here’s the style I want: [example]”)
  • Include a “avoid” list: no “Exciting news!”, no em-dash overuse, no “Let’s dive in”
  • For LinkedIn, specify: “Write from first-person perspective, share one concrete lesson, end with a question to the reader”

After two weeks of reviewing output and refining the prompt, the posts should require minimal editing before you’d be comfortable putting your name on them.

Final Verdict

This setup takes an afternoon to build and runs indefinitely with almost no maintenance. The combination of n8n’s visual workflow editor, OpenAI’s cheap text generation, and Buffer’s scheduling layer covers the full pipeline without requiring custom code beyond a few lines of JSON parsing.

Start with the basic five-node workflow this week. Get one platform working end-to-end before adding the others. Once you trust the output quality, expand the batch size and layer in more platforms. Your future self will thank you for the three hours you spent building this instead of manually drafting posts every morning.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *