Skip to content

About

A production-ready human-in-the-loop approval system for n8n workflows. This service acts as a bridge between your n8n content generation workflow and your posting workflow, allowing manual approval via Discord before content gets published.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

16 Commits

Folders and files

Repository files navigation

N8N Approval Service

A production-ready human-in-the-loop approval system for n8n workflows. This service acts as a bridge between your n8n content generation workflow and your posting workflow, allowing manual approval via Discord before content gets published.

Dashboard Preview

🎯 Features

  • Modern Dashboard UI: Clean, intuitive interface with real-time post statistics (Pending, Approved, Rejected, Posted)
  • Post Management: View and manage all posts with filtering by status (All, Pending, Approved, Rejected, Posted)
  • Quick Actions: One-click approve, reject, view, and delete actions directly from the dashboard
  • Post Submission API: Receive posts from n8n with automatic Discord notifications
  • Discord Integration: Rich embed notifications with clickable Approve/Reject buttons
  • Two-Workflow Model: Separates content generation from posting for clean workflow design
  • Configuration Page: Easy setup for Discord webhooks and n8n integration
  • PostgreSQL Storage: Reliable persistence for all posts and settings
  • Docker Ready: Full containerization with docker-compose
  • Social Media Integration: Quick links to GitHub, Ko-fi, and GitHub Sponsors

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  n8n Workflow 1 │────▢│  N8N Approval Service │────▢│     Discord     β”‚
β”‚ (Content Gen)   β”‚     β”‚                       β”‚     β”‚   (Approval)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚                          β”‚
                                    β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚      (Approve/Reject)
                                    β”‚
                                    β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  n8n Workflow 2       β”‚
                        β”‚  (Post to LinkedIn)   β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ Prerequisites

  • Docker and Docker Compose
  • Discord server with webhook access
  • n8n instance (self-hosted or cloud)

πŸš€ Quick Start

1. Clone and Configure

# Clone the repository
git clone <your-repo-url>
cd N8N-Approval-Service

# Copy environment file
cp .env.example .env

# Edit .env with your settings
nano .env

2. Start with Docker Compose

# Build and start containers
docker-compose up -d

# View logs
docker-compose logs -f app

3. Access the Dashboard

Open your browser and navigate to http://localhost:3001

4. Configure Discord

  1. Go to the Setup page (/setup)
  2. Enter your Discord Webhook URL
  3. Click Save Settings

πŸ“‘ API Endpoints

Submit a Post (from n8n Workflow 1)

POST /api/v1/posts/submit
Content-Type: application/json

{
  "content": "Your post content here...",
  "source": "LinkedIn AI Generator",
  "n8n_callback_url": "https://your-n8n.com/webhook/abc123"
}

Response:

{
  "success": true,
  "message": "Post submitted successfully and pending approval",
  "data": {
    "id": 1,
    "status": "PENDING",
    "created_at": "2024-01-01T00:00:00.000Z"
  }
}

Approve a Post (Discord Link)

GET /api/v1/posts/{post_id}/approve

Returns HTML confirmation page and triggers callback to n8n Workflow 2.

Reject a Post (Discord Link)

GET /api/v1/posts/{post_id}/reject

Returns HTML confirmation page. No callback is sent.

Mark Post as Posted (from n8n Workflow 2)

PUT /api/v1/posts/{post_id}/posted

Response:

{
  "success": true,
  "message": "Post marked as posted successfully",
  "data": {
    "id": 1,
    "status": "POSTED",
    "posted_at": "2024-01-01T00:00:00.000Z"
  }
}

List Posts

GET /api/v1/posts?status=PENDING&limit=50&offset=0

Get Post Statistics

GET /api/v1/posts/stats/summary

βš™οΈ n8n Workflow Setup

Workflow 1: Content Submission

  1. Content Generation Node: Create your content (AI, manual, etc.)
  2. HTTP Request Node:
    • Method: POST
    • URL: http://your-approval-service:3001/api/v1/posts/submit
    • Body:
      {
        "content": "{{ $json.generated_content }}",
        "source": "My Content Workflow",
        "n8n_callback_url": "https://your-n8n.com/webhook/posting-workflow"
      }

Workflow 2: Posting (Triggered by Approval)

  1. Webhook Trigger: Create a webhook (use this URL as n8n_callback_url)
  2. LinkedIn Node: Post the content from {{ $json.post_content }}
  3. HTTP Request Node (after successful post):
    • Method: PUT
    • URL: http://your-approval-service:3001/api/v1/posts/{{ $json.post_id }}/posted

πŸ”§ Configuration

Environment Variables

Variable Description Default
PORT Server port 3001
APP_URL Public URL of the service http://localhost:3001
DATABASE_URL PostgreSQL connection string (see docker-compose)
DB_PASSWORD Database password approval_pass
DISCORD_WEBHOOK_URL Discord webhook URL (optional)
N8N_BASE_URL n8n base URL (reference only) (optional)

Database

The service uses PostgreSQL with the following schema:

Posts Table:

  • id - Primary key
  • content - Post content (TEXT)
  • source - Source/workflow name (VARCHAR)
  • status - PENDING, APPROVED, REJECTED, POSTED
  • n8n_callback_url - Callback URL for Workflow 2
  • created_at - Creation timestamp
  • approved_at - Approval timestamp
  • posted_at - Posted timestamp

Settings Table:

  • key - Setting key (unique)
  • value - Setting value

🐳 Docker Commands

# Start services
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs -f

# Rebuild after changes
docker-compose up -d --build

# Reset database
docker-compose down -v
docker-compose up -d

πŸ› οΈ Development

Local Development Setup

# Install backend dependencies
npm install

# Install frontend dependencies
cd frontend && npm install && cd ..

# Generate Prisma client
npm run prisma:generate

# Start PostgreSQL (or use docker-compose)
docker-compose up -d db

# Run database migrations
DATABASE_URL="postgresql://approval_user:approval_pass@localhost:5432/approval_db" npm run prisma:migrate:dev

# Start backend in dev mode
npm run dev

# In another terminal, start frontend
cd frontend && npm run dev

Project Structure

N8N-Approval-Service/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Express server entry
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   └── prisma.ts         # Prisma client
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ posts.routes.ts   # Posts API endpoints
β”‚   β”‚   └── settings.routes.ts # Settings API endpoints
β”‚   └── services/
β”‚       └── discord.service.ts # Discord webhook integration
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.tsx           # Main app component
β”‚   β”‚   β”œβ”€β”€ main.tsx          # React entry point
β”‚   β”‚   β”œβ”€β”€ api/              # API client
β”‚   β”‚   β”œβ”€β”€ components/       # Shared components
β”‚   β”‚   β”œβ”€β”€ pages/            # Page components
β”‚   β”‚   └── types/            # TypeScript types
β”‚   └── ...
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma         # Database schema
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
└── package.json

πŸ“„ License

MIT License - see LICENSE file for details.

❀️ Support

If you find this project useful, consider supporting:

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

πŸ“Š Repository Activity

Alt

About

A production-ready human-in-the-loop approval system for n8n workflows. This service acts as a bridge between your n8n content generation workflow and your posting workflow, allowing manual approval via Discord before content gets published.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages