AI-Powered LinkedIn Ghostwriting Engine by Bhavy ShekhaliyaAI-Powered LinkedIn Ghostwriting Engine by Bhavy Shekhaliya

AI-Powered LinkedIn Ghostwriting Engine

Bhavy Shekhaliya

Bhavy Shekhaliya

AI-Powered LinkedIn Ghostwriting Engine using RAG & Multi-Agent AI

Project Type: AI Automation & Workflow Architecture Tech Stack: n8n, OpenAI, Supabase (Vector DB/pgvector), Telegram Bot API, LinkedIn API

πŸ“Œ Project Overview

Creating consistently viral content on LinkedIn is incredibly time-consuming. My client a busy B2B founder wanted to systemize their content creation by leveraging their personal "swipe file" of highly engaging LinkedIn posts.
To solve this, I designed and built an end-to-end Retrieval-Augmented Generation (RAG) system using n8n. The system consists of a Telegram bot to instantly save viral posts to a Vector Database, and a multi-agent AI web app that generates fresh, highly optimized LinkedIn posts by learning from the saved viral content.

🚧 The Challenge

Friction in Content Curation: The client was manually copy-pasting good LinkedIn posts into a messy Notion document.
Generic AI Output: Standard ChatGPT prompts produced robotic, generic-sounding LinkedIn posts that didn't match the pacing, hooks, and formatting of truly viral content.
Disconnected Tools: They needed a centralized, low-friction way to collect data and generate content in one seamless pipeline.

πŸ’‘ The Solution & Architecture

I built a completely automated, two-module workflow within n8n that operates as a dedicated AI marketing team:

Module 1: Viral Post Collection (The "Swipe File" Builder)

Seamless Curation via Telegram: The client simply forwards a LinkedIn post URL to a custom Telegram bot.
Automated Web Scraping: n8n intercepts the URL, validates it, and automatically scrapes the main commentary from the LinkedIn HTML.
Vector Database Storage: The scraped text is converted into vector embeddings using OpenAI (text-embedding-ada-002) and stored in a Supabase Vector DB (using pgvector), making the content searchable by AI.

Module 2: The Multi-Agent AI Content Generator

When the client wants to write a new post, they submit a simple "hook" or "topic" into a custom n8n Web Form. This triggers a 3-Stage Multi-Agent AI pipeline:
Hook Analysis Agent: Extracts the core topic, industry niche, emotional tone, and 3-5 key points from the user's input.
Post Structure Agent: Dynamically builds a 5-section structural outline (Hook, Problem, Value/Lesson, Solution, CTA).
RAG Post Generator: This is where the magic happens. The AI queries the Supabase Vector Store to retrieve the top 5 most similar viral posts collected in Module 1. It analyzes their formatting, hook styles, and sentence lengths, then generates a brand new post that mimics proven viral patterns.
Auto-Publishing: The final output is either formatted for manual review or automatically pushed live via the LinkedIn API.

βš™οΈ Key Technical Highlights

Retrieval-Augmented Generation (RAG): By feeding the LLM actual examples of top-performing posts relevant to the topic, the output bypasses the "AI-sounding" tone completely.
Agentic Workflows: Instead of one massive prompt, the task is split between three distinct AI agents (Hook Analyzer, Structurer, Generator), drastically reducing hallucinations and improving output quality.
Dual-Model Fallbacks: Integrated both OpenAI (GPT-4o-mini) and Google Gemini (2.5-flash) with fail-safes to ensure 100% uptime and structured JSON outputs.

πŸ“ˆ The Results

90% Reduction in Content Creation Time: What used to take 45 minutes of drafting and editing now takes 3 minutes.
Zero-Friction Curation: The client grew their swipe file database to over 500+ viral posts just by sending URLs to Telegram while scrolling on their phone.
Increased Engagement: Because the AI was mimicking proven viral structures (short sentences, strong hooks, clear CTAs), the generated posts saw a 3x higher impression rate compared to baseline ChatGPT outputs.
Looking to build a custom AI agent, RAG system, or automate your marketing pipelines?
Let's chat! I specialize in building custom low-code and code-first AI architectures using n8n, Make, OpenAI, and Vector Databases.
Like this project

Posted Mar 4, 2026

AI-powered n8n ghostwriting system. Uses RAG, Supabase, and multi-agent AI to transform saved posts into viral LinkedIn content automatically.