DEV Community

Time Pass
Time Pass

Posted on

Complete Guide: Building an Automated Blog Publishing System with n8n

Complete Guide: Building an Automated Blog Publishing System with n8n

If you're a developer who blogs, you know the struggle: you write the content, but formatting, tagging, and uploading it to multiple platforms is a tedious chore.

In this guide, we will set up a robust, end-to-end automation in n8n that converts a raw idea into a professional, formatted Markdown article ready for publication on platforms like Dev.to, Hashnode, or your personal Ghost site.

The Automation Workflow

  1. Trigger: Receive a request from a Google Sheet, Notion page, or Webhook.
  2. AI Drafting: Use OpenAI (GPT-4) to structure and write the content.
  3. Formatting: Use a Code node to apply custom frontmatter and cleaning.
  4. Publishing: Automatically push to your destination platform (Dev.to/GitHub).

Step-by-Step Setup

Step 1: The Trigger

Create a new workflow and add the Webhook node. This will be your input gateway.

  • Set it to POST.
  • This allows you to trigger your workflow from a Notion "Publish" button or a simple terminal curl command.

Step 2: Content Generation (OpenAI)

Drag an OpenAI node onto the canvas. Use the Chat resource.

  • System Prompt: "You are a technical editor. Write detailed articles in Markdown. Use H2 headers, include code blocks for technical examples, and summarize key concepts at the end."
  • User Prompt: Pass the data from your webhook as the input topic.

Step 3: Standardizing with a Code Node

Standardization is key. Add a Code node to wrap your generated content with metadata (Frontmatter) required by your site.

// Ensure every post has standard frontmatter
const frontmatter = `--- 
title: ${items[0].json.title}
date: ${new Date().toISOString()}
tags: ["development", "automation"]
---

`;

return {
  title: items[0].json.title,
  body: frontmatter + items[0].json.generated_content
};
Enter fullscreen mode Exit fullscreen mode

Step 4: The Publishing Engine (Dev.to API)

Use the HTTP Request node to push the draft to Dev.to.

  • URL: https://dev.to/api/articles
  • Method: POST
  • Headers: api-key: YOUR_DEVTO_KEY
  • Send Body: true
  • Body Content:
{
  "article": {
    "title": "{{ $json.title }}",
    "body_markdown": "{{ $json.body }}",
    "published": false
  }
}
Enter fullscreen mode Exit fullscreen mode

Why This Approach Wins

  • Platform Agnostic: You can duplicate the last step in your n8n workflow to push to both Dev.to and your personal site simultaneously.
  • Error Handling: Use n8n's "Error Trigger" to get a Slack or Discord alert if the AI fails or the API goes down.
  • Modularity: Want to change your publishing platform? You only need to swap the final HTTP Request node—the rest of your AI pipeline stays exactly the same.

Finalizing Your Setup

  1. Test: Use the 'Execute Workflow' button in the n8n editor with sample JSON.
  2. Activate: Toggle the Active switch in the top right to turn the webhook live.
  3. Refine: As you use it, tweak your System Prompt in the OpenAI node. Adding specific examples of your own writing style to the prompt will make the AI output feel more human over time.

By treating your blog content as data flowing through an infrastructure pipeline, you move from manual effort to a scalable, professional content strategy.

Top comments (0)