Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Powered Blog Content Generator

An automated system for generating human-like blog posts for social media niches using n8n workflow.

Overview

This project combines Next.js REST API service with n8n workflows to create an automated blog post generation system. It leverages various AI services and APIs to generate high-quality, unique content with built-in similarity checking to avoid duplicates.

Tech Stack

  • Backend API: Next.js with MongoDB
  • Workflow Automation: n8n
  • AI Services:
    • OpenAI API (for embeddings and content generation)
    • Anthropic API (for human-like blog writing)
    • Google Serper API (for keyword research)
    • Perplexity Research API (optional, for topic research)
  • Storage: AWS S3 (for saving blog images)
  • Tunnel: ngrok (for exposing local API)

Project Structure

  • n8n-blog-rest-api/: Next.js REST API service with RAG functionality
  • n8n-config/: n8n workflow configurations and Docker setup

Setup Instructions

1. REST API Service Setup

  1. Navigate to n8n-blog-rest-api/:
cd n8n-blog-rest-api
npm install
  1. Configure environment variables:
    • Copy .example.env to .env
    • Fill in the required variables:
OPENAI_API_KEY=your_openai_api_key
MONGO_URL=mongodb+srv://${DB_USER_NAME}:${DB_PASSWORD}@cluster0.smdgg5t.mongodb.net/spybroski
SERVICE_API_KEY=your_generated_api_key (openssl rand -hex 32)
NEXT_PUBLIC_HOST=your_ngrok_url # Will be updated after ngrok setup
  1. Start the service:
npm run dev

2. Setting up ngrok for API Access

Since the local Next.js API needs to be accessible from the internet, we'll use ngrok to create a secure tunnel.

  1. Install ngrok:
# Using npm
npm install -g ngrok

# Or using Homebrew on macOS
brew install ngrok
  1. Sign up for a free ngrok account at https://ngrok.com and get your authtoken

  2. Configure ngrok:

ngrok config add-authtoken your_authtoken
  1. Start ngrok tunnel:
ngrok http 3000
  1. Update your environment variables:
    • Copy the HTTPS URL provided by ngrok (e.g., https://your-domain.ngrok.io) and use in n8n-config/blog-workflow.json when specifying service host

For more details about ngrok setup and features, visit: ngrok Documentation

3. n8n Workflow Setup

  1. Navigate to n8n-config/

  2. Configure the workflow:

    • Open blog-workflow.json
    • Replace ${YOUR_HOST} with your ngrok URL
    • Replace ${YOUR_API_KEY} with your SERVICE_API_KEY
    • Replace ${YOUR_GOOGLE_SERPER_API_KEY} with your ${YOUR_GOOGLE_SERPER_API_KEY} (https://serper.dev/)
  3. Go back to root directory and Start n8n using Docker:

docker compose up -d
  1. Access n8n:
    • Open http://localhost:5678/workflow/
    • Import blog-workflow.json (https://ibb.co/YBnmPCC8)
    • Configure API keys for all services:
      • OpenAI
      • Google Serper
      • Anthropic
      • AWS S3
      • Other service providers as needed

API Endpoints

  • GET /api/blogs/latest: Retrieve latest blog posts
  • POST /api/blogs/check-similarity: Check if similar blog content exists
  • POST /api/blogs: Create new blog post
  • GET /api/blogs/[slug]: Get specific blog by SEO-optimized slug
  • GET /api/blogs: Get all blogs

Workflow Features

The n8n workflow handles:

  1. Topic research and keyword optimization
  2. Blog title and meta generation
  3. SEO-friendly slug creation
  4. Blog cover image prompt generation
  5. Human-like content creation using Anthropic AI
  6. Image storage in AWS S3
  7. Content similarity checking
  8. Database storage

Required API Keys

  • OpenAI API key
  • Google Serper API key (free with registration) (https://serper.dev/)
  • Anthropic API key
  • AWS S3 credentials
  • MongoDB connection string
  • Perplexity Research API key

Running the Complete System

  1. Start the REST API service (runs on port 3000)
  2. Start ngrok tunnel to expose your API
  3. Launch n8n using Docker (available on port 5678)
  4. Import and configure the workflow in n8n
  5. Execute the workflow to start generating content

Important Notes:

  • The ngrok URL changes every time you restart the tunnel unless you have a paid plan
  • Update your NEXT_PUBLIC_HOST and n8n workflow configuration whenever the ngrok URL changes
  • For production use, consider using a paid ngrok plan or a proper reverse proxy setup

For detailed customization options and advanced configurations, refer to the individual service directories.

n8n Workflow Preview

About

An automated system for generating human-like blog posts for social media niches using n8n workflow.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages