How to Build an AI Agent That Generates and Posts Content Automatically
Building a content automation pipeline using AI agents, n8n workflows, and scheduling. From raw idea to published post — here's the full architecture and the practical setup that actually works.
On this page
Content creation is creative work. Content publishing is logistics. The two are different problems, and only one of them should take your time.
The automation side — formatting, scheduling, publishing, distributing — is entirely automatable with AI agents and workflow tools. Here's how to build it.
The Architecture
A content automation pipeline has five stages:
Input (idea/outline)
→ Content Generation (AI)
→ Review/Edit (human or AI)
→ Formatting + Asset Creation
→ Publishing + DistributionEach stage can be automated to different degrees. The content generation stage benefits from human input (your ideas, your voice, your domain knowledge). Everything after that is logistics.
Tools in the Stack
n8n — open-source workflow automation. Self-hostable, visual node editor, connects to any API. The backbone of the pipeline.
OpenAI / Claude API — content generation. Claude is better for long-form technical content; GPT-4o is solid for varied formats.
ElevenLabs — voice generation for audio/video formats (optional for written content pipelines).
Buffer / Typefully / Beehiiv API — publishing to social platforms or newsletters.
GitHub API / Netlify API — for blogs built on static site generators (like this one).
Stage 1: Input Collection
The input doesn't need to be polished. The AI will shape it. You need:
- A topic (1 sentence)
- Your angle or perspective (1-3 bullet points)
- Any specific data, examples, or personal experiences to include
{
"topic": "Why automation testing fails in most teams",
"angle": [
"Teams automate too early, before features stabilize",
"Flaky tests are worse than no tests",
"No maintenance budget = degraded suite"
],
"examples": "Personal experience with Fire OS testing and 18-platform device labs"
}You can submit this via a simple form, a Notion database row, an Airtable record, or a Slack message — n8n can trigger from all of these.
Stage 2: Content Generation (n8n + Claude API)
// n8n Function node — build prompt from input
const topic = $json["topic"];
const angle = $json["angle"].join("\n- ");
const examples = $json["examples"];
const prompt = `You are a technical writer with 13 years of QA experience.
Write a professional blog post about: ${topic}
My specific angle:
- ${angle}
Include these personal examples: ${examples}
Requirements:
- 800-1200 words
- Direct, confident voice. No filler.
- Include a comparison table
- Include at least one practical code example
- Use callout boxes for key warnings/tips
- MDX format with frontmatter (title, date, summary, tags)`;
return [{ json: { prompt } }];// n8n HTTP Request node — call Claude API
{
"method": "POST",
"url": "https://api.anthropic.com/v1/messages",
"headers": {
"x-api-key": "{{$env.ANTHROPIC_API_KEY}}",
"anthropic-version": "2023-06-01",
"content-type": "application/json"
},
"body": {
"model": "claude-opus-4-5",
"max_tokens": 4096,
"messages": [
{ "role": "user", "content": "{{$json.prompt}}" }
]
}
}Stage 3: Review Checkpoint
Fully automated publishing without human review works for high-volume, lower-stakes content (social posts, short-form). For long-form technical content on your professional blog, keep a review step.
Option A: Async review (recommended)
The generated content goes to a staging area (a private Notion page, a draft in your CMS, a GitHub PR). You review asynchronously and approve with a button press that triggers the next stage.
Option B: AI review pass
Before publishing, run the content through a second AI prompt that checks for:
- Factual errors or claims that need verification
- Inconsistencies with your established voice
- Missing context that a reader would need
"Review this blog post draft. Flag:
1. Any factual claims that should be verified
2. Any sections that feel vague or incomplete
3. The overall quality rating: Good/Needs-Edit/Rewrite
If Good, output: APPROVED
If Needs-Edit, output: EDIT: [specific changes needed]"This creates a semi-automated review loop that catches obvious issues without requiring your attention for every post.
Stage 4: Publishing to a Static Blog (GitHub + Cloudflare)
For a Next.js blog on Cloudflare Pages (the setup described elsewhere on this site):
// n8n GitHub node — create the post file
{
"operation": "createFile",
"owner": "SUDARSHANCHAUDHARI",
"repository": "website",
"filePath": "content/posts/{{$json.slug}}.mdx",
"fileContent": "{{$json.content}}",
"commitMessage": "Add blog post: {{$json.title}}",
"branch": "post/{{$json.slug}}"
}Then trigger PR creation via the GitHub API. The CI pipeline picks it up, builds, and deploys to Cloudflare Pages on merge.
[!TIP] Keep the automation creating branches and PRs rather than pushing directly to main. This gives you a review step that matches your existing git workflow, and the PR history is a useful log of your published content.
Stage 5: Distribution
After publishing, distribute to your channels:
LinkedIn post — summarize the article in 3-4 paragraphs:
// Generate LinkedIn-optimized summary
const linkedInPrompt = `Convert this blog post into a LinkedIn post.
- 250-400 words
- Professional tone
- End with "Read the full post: [URL]"
- Use line breaks for readability
- No hashtag spam (max 3 relevant hashtags)`;Twitter/X thread — break the key points into a thread:
const threadPrompt = `Convert this blog post into a Twitter thread.
- 6-8 tweets
- Each tweet max 250 characters
- Start with the most compelling hook
- End with: "Full post: [URL]"`;Newsletter — if you have a Beehiiv or Substack:
// Beehiiv API — create draft post
{
"method": "POST",
"url": "https://api.beehiiv.com/v2/publications/{{PUB_ID}}/posts",
"body": {
"title": "{{$json.title}}",
"content": "{{$json.newsletterContent}}",
"status": "draft"
}
}The Full n8n Workflow
Trigger (Notion/Airtable row created)
↓
Build Prompt (Function node)
↓
Generate Content (Claude API)
↓
Generate Slug + Frontmatter (Function node)
↓
Create GitHub Branch (GitHub node)
↓
Commit MDX File (GitHub node)
↓
Create PR (GitHub API)
↓
Send Slack Notification: "Review ready: [PR URL]"
↓
[Human reviews PR and merges]
↓
GitHub Webhook: PR merged
↓
Generate Social Variations (Claude API)
↓
Schedule LinkedIn Post (Buffer API)
↓
Schedule Twitter Thread (Buffer API)What This Actually Saves
For a daily posting cadence:
- Without automation: 2-3 hours per post (writing, formatting, publishing, distributing)
- With automation: 20-30 minutes per post (input, review, approve)
At daily posting, that's 10-15 hours per week recovered. The quality is comparable — the AI handles the mechanical parts; your ideas and review handle the quality.
The goal isn't to remove yourself from the content. It's to remove yourself from the logistics. Your thinking time should go to the ideas and the strategy, not to formatting MDX files and scheduling LinkedIn posts.
That's what this pipeline delivers.
Sudarshan Chaudhari
AI Systems Builder / Product Engineer
Bangkok, Thailand
Solo Android developer with 13+ years in QA, building Android apps, AI automation systems, and developer tools at SudarshanTechLabs.
Related Posts
Building something? Available for Android dev and QA consulting.
Work with meComments — powered by Giscus
