Generate LinkedIn posts using Telegram, Supabase vector DB and OpenAI RAG
Overview AI-powered n8n workflow that creates viral LinkedIn posts by learning from successful content. Features two modules: (1) Telegram-based scraper that builds a vector database of viral LinkedIn posts, and (2) Web form that generates optimized posts using multi-agent AI with RAG (Retrieval-Augmented Generation) from your curated viral content library.
Key Capabilities: Scrapes LinkedIn post content via Telegram bot Stores posts in Supabase vector database with OpenAI embeddings 3-agent system analyzes hooks, structures outlines, and generates posts RAG integration retrieves similar viral posts for pattern matching Auto-publishes to LinkedIn or provides formatted output
How It Works
Module 1: Viral Post Collection (Telegram Bot)
Step 1: URL Validation User sends LinkedIn post URL to Telegram bot Workflow validates URL contains "linkedin.com" Shows typing indicator for better UX
Step 2: Content Scraping HTTP request fetches post HTML CSS selector extracts main commentary: [data-test-id="main-feed-activity-card__commentary"] Handles scraping failures with error messages
Step 3: Vector Storage Converts post text to OpenAI embeddings (text-embedding-ada-002) Stores in Supabase linkedin_post table with vector indexing Sends success confirmation via Telegram
Module 2: AI Post Generation (Web Form)
Stage 1: Hook Analysis Agent Input**: User-provided hook text Process**: AI extracts topic, niche/industry, emotional tone, and 3-5 key points Output**: Structured JSON with analyzed elements Models**: GPT-4o-mini or Gemini 2.5-flash (dual fallback)
Stage 2: Post Structure Agent Input**: Analyzed hook data Process**: Creates 5-section outline (Hook, Problem, Value/Lesson, Solution, CTA) Output**: Structured framework for final post Models**: GPT-4o-mini or Gemini 2.5-flash
Stage 3: Post Generator Agent (RAG) Input**: Post structure + topic RAG Process**: Queries Supabase vector store for 5 most similar viral posts Analyzes patterns: hooks, storytelling, CTAs, engagement metrics Identifies optimal length, formatting, and emotional triggers Output**: Complete LinkedIn post applying viral patterns Models**: GPT-4o-mini or Gemini 2.5-flash with GPT-5-NANO for structured output
Stage 4: Publication Auto-publishes to LinkedIn via API Or returns formatted post text for manual posting
How To Use
Setup
-
Configure Supabase Vector Database Create Supabase project Create table: linkedin_post with vector column (1536 dimensions for OpenAI embeddings) Enable vector extension: CREATE EXTENSION vector; Update credentials in "Upload Document" and "Supabase Vector Store" nodes
-
Set Up Telegram Bot (Module 1) Create bot via @BotFather Get bot token and update "On Telegram Message" credentials Start bot and get your chat ID Activate workflow
-
Configure OpenAI API Add API key to "Embeddings" nodes (both modules) Configure language model credentials (GPT-4o-mini, GPT-5-NANO)
-
Set Up LinkedIn API (Optional for Module 2) Create LinkedIn app with member permissions Configure OAuth2 credentials in "Create a post" node Or remove node to get text output only
-
Access Web Form Get form URL from "LinkedIn Form" webhook Bookmark for easy access
Related Templates
Convert Tour PDFs to Vector Database using Google Drive, LangChain & OpenAI
🧩 Workflow: Process Tour PDF from Google Drive to Pinecone Vector DB with OpenAI Embeddings Overview This workflow au...
Provide latest euro exchange rates from European Central Bank via Webhook
What is this workflow doing? This simple workflow is pulling the latest Euro foreign exchange reference rates from the E...
Automate Daily Keyword Research with Google Sheets, Suggest API & Custom Search
Who's it for This workflow is perfect for SEO specialists, marketers, bloggers, and content creators who want to automa...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments