This workflow corresponds to n8n.io template #11385 — we link there as the canonical source.
This workflow follows the Agent → Documentdefaultdataloader recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"nodes": [
{
"id": "4bb14abf-a994-42cc-ae2c-794b3f8fffc9",
"name": "On Telegram Message",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
560,
480
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "68cb5738-cc56-46e1-819b-6edf51d31ebe",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
784,
560
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "7c6b795c-d713-42f4-8b7d-3bc6402f926e",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.message.text && $json.message.text.includes(\"linkedin.com\") }}",
"rightValue": ""
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "11eb73d0-a694-468a-9d14-fb83a29297aa",
"name": "Typing....",
"type": "n8n-nodes-base.telegram",
"position": [
784,
384
],
"parameters": {
"chatId": "={{ $json.message.chat.id }}",
"operation": "sendChatAction"
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "78aadce3-59f1-45b2-a823-9c682b411029",
"name": "Wrong URL",
"type": "n8n-nodes-base.telegram",
"position": [
1024,
640
],
"parameters": {
"text": "\u26a0\ufe0f Please provide a valid LinkedIn post URL",
"chatId": "={{ $('On Telegram Message').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "861e1884-8bc0-4592-b974-d6ca8ae38fd6",
"name": "LinkedIn Post URL",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
1024,
464
],
"parameters": {
"url": "={{ $('On Telegram Message').item.json.message.text }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "debbf493-7fdb-46c7-a277-d26fac22e849",
"name": "Scrap Content",
"type": "n8n-nodes-base.html",
"position": [
1264,
368
],
"parameters": {
"options": {},
"operation": "extractHtmlContent",
"extractionValues": {
"values": [
{
"key": "Post Content",
"cssSelector": "[data-test-id=\"main-feed-activity-card__commentary\"]"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "65ea81c0-342d-485e-9771-a84719ea41b2",
"name": "Unable to Scrape",
"type": "n8n-nodes-base.telegram",
"position": [
1264,
544
],
"parameters": {
"text": "\ud83d\ude36 Scraping failed for this LinkedIn post",
"chatId": "={{ $('On Telegram Message').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "fd1d9092-393d-49d2-b693-8bcb2ed61e1a",
"name": "Upload Document",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
1536,
368
],
"parameters": {
"mode": "insert",
"options": {},
"tableName": {
"__rl": true,
"mode": "list",
"value": "linkedin_post",
"cachedResultName": "linkedin_post"
},
"embeddingBatchSize": 500
},
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "602d6dad-666f-4b9d-bc37-3d03bbbb66c3",
"name": "Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1632,
576
],
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "caea9de5-649d-4e25-838c-565e16d712aa",
"name": "Embeddings",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
1504,
576
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "0ad1ad5c-00a4-452c-9e08-575d0fe8b8f5",
"name": "\u2705 Post Scrapped Sucessfully",
"type": "n8n-nodes-base.telegram",
"position": [
2048,
368
],
"parameters": {
"text": "\u2705 Post Scraped successfully",
"chatId": "={{ $('On Telegram Message').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "c19bcbfd-8e9b-43e7-bdb3-6560dda1ed46",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
1856,
368
],
"parameters": {
"jsCode": "return $('Upload Document').all()[0]"
},
"typeVersion": 2
},
{
"id": "b816d602-5db4-4d0f-8dc0-8f13cff96dcd",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
480,
208
],
"parameters": {
"color": 6,
"width": 1792,
"height": 624,
"content": "## \ud83d\udccc Viral LinkedIn Post Vector Database\n- Transform any LinkedIn post URL into actionable insights. This workflow scrapes post content via Telegram, stores it in a vector database with AI embeddings, and builds your personal repository of viral content patterns for future post creation."
},
"typeVersion": 1
},
{
"id": "79e6152b-3ed6-453a-8e22-883f82a6f7af",
"name": "LinkedIn Form",
"type": "n8n-nodes-base.formTrigger",
"position": [
560,
1248
],
"parameters": {
"options": {
"path": "linkedin-post",
"ignoreBots": true,
"buttonLabel": "Generate",
"appendAttribution": false
},
"formTitle": "LinkedIn - Bhavy Shekhaliya",
"formFields": {
"values": [
{
"fieldType": "textarea",
"fieldLabel": "Hook",
"requiredField": true
},
{
"fieldLabel": "Post Image"
}
]
}
},
"typeVersion": 2.3
},
{
"id": "9eacf1f3-464d-46d4-833a-2031e27c5656",
"name": "Hook Analyse Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
752,
1248
],
"parameters": {
"text": "=You are an expert LinkedIn strategist.\n\nAnalyze the following hook:\n\"{{ $json.Hook }}\"\n\nExtract:\n- topic\n- niche or industry (e.g. Shopify, Agency, Health)\n- emotion/tone (educational, inspirational, contrarian, etc.)\n- 3 to 5 key points that the post should cover",
"options": {},
"promptType": "define",
"needsFallback": true,
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "04f3b813-0bf5-4092-bb28-98b616b49591",
"name": "Post Structure Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1152,
1248
],
"parameters": {
"text": "=You are a viral content strategist for LinkedIn.\n\nUsing the details below, create a structured LinkedIn post outline with 5 sections:\n1. Hook\n2. Problem\n3. Value or Lesson\n4. Solution or Takeaway\n5. Call-to-action (CTA)\n\nTopic: {{ $json.output.topic }}\nIndustry: {{ $json.output.niche }}\nTone: {{ $json.output.tone }}\nKey Points: {{ $json.output.key_points }}",
"options": {},
"promptType": "define",
"needsFallback": true,
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "c98a7b27-f13e-40a4-96ea-3de9d5130bde",
"name": "Post Generator Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1552,
1248
],
"parameters": {
"text": "=You are an expert LinkedIn ghostwriter with access to a Vector Database containing viral LinkedIn posts. This database includes proven patterns, structures, and topics that have generated massive engagement.\n\n# Task\nAnalyze the Vector Database for similar viral posts related to the given topic, then generate a high-performing LinkedIn post using proven viral elements.\n\n# Vector Database Analysis Process:\n## Step 1: Topic Matching\n- Search the Vector Database for the 5-10 most relevant viral posts matching the user's topic\n- Identify common patterns in hooks, storytelling techniques, and CTAs\n- Extract engagement metrics from similar posts\n\n## Step 2: Pattern Recognition\n\n- Analyze what made these posts go viral (emotional triggers, formatting, timing)\n- Identify recurring themes, word choices, and structural elements\n- Note the optimal post length and formatting style for this topic\n\n## Step 3: Structure Application\n- Based on Vector Database insights, apply the proven viral structure:\n\nData:\nHook: {{ $json.output.structure.hook }}\nProblem: {{ $json.output.structure.value }}\nValue: {{ $json.output.structure.value }}\nSolution: {{ $json.output.structure.solution }}\nCTA: {{ $json.output.structure.cta }}",
"options": {},
"promptType": "define",
"needsFallback": true,
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "9bf9eb00-7648-4967-868e-8ad221553f7a",
"name": "4o mini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1136,
1024
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "328bc5db-1ed7-4c66-ab9d-41d9e3159974",
"name": "2.5-flash",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
1312,
1024
],
"parameters": {
"options": {}
},
"typeVersion": 1
},
{
"id": "e2c7b0ab-bac7-4a03-9cd5-4aaf45c2ae9b",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
864,
1472
],
"parameters": {
"autoFix": true,
"jsonSchemaExample": "{\n \"topic\": \"Shopify automation\",\n \"niche\": \"E-commerce\",\n \"tone\": \"educational\",\n \"key_points\": [\n \"Manual customer replies waste time\",\n \"AI automation saves hours per week\",\n \"Shopify tools integrate seamlessly\",\n \"Boost productivity and sales\"\n ]\n}"
},
"typeVersion": 1.3
},
{
"id": "146a8ee2-28ca-4cf8-871b-43631c961427",
"name": "5 nano",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1264,
1680
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-5-nano",
"cachedResultName": "gpt-5-nano"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "9559c8eb-7781-48ab-b967-d919b344af42",
"name": "Structured Output Parser.",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1264,
1472
],
"parameters": {
"autoFix": true,
"jsonSchemaExample": "{\n \"structure\": {\n \"hook\": \"\ud83d\ude80 How a Shopify store owner saved 12 hours/week by automating replies\",\n \"problem\": \"Manual replies were taking hours daily.\",\n \"value\": \"AI automation now handles 90% of questions instantly.\",\n \"solution\": \"Connected Shopify inbox with AI-driven autoresponder.\",\n \"cta\": \"Want to save your time too? Comment 'AUTOMATE' below \ud83d\udcac\"\n }\n}"
},
"typeVersion": 1.3
},
{
"id": "1a5c9cb7-208b-484c-b138-f10ce85386fa",
"name": "Supabase Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
1616,
1648
],
"parameters": {
"mode": "retrieve-as-tool",
"topK": 5,
"options": {},
"tableName": {
"__rl": true,
"mode": "list",
"value": "linkedin_post",
"cachedResultName": "linkedin_post"
},
"toolDescription": "You are helpful assistant"
},
"typeVersion": 1.3
},
{
"id": "66cbb3fb-2587-48d0-893d-8d6b1a47121f",
"name": "Embeddings.",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
1616,
1824
],
"parameters": {
"options": {}
},
"typeVersion": 1.2
},
{
"id": "bc29a541-ff40-4f49-8207-c363a152986b",
"name": "Structured Output Parser1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1664,
1472
],
"parameters": {
"autoFix": true,
"jsonSchemaExample": "{\n\t\"Post Content\": \"Post Content\"\n}"
},
"typeVersion": 1.3
},
{
"id": "70d2059b-1b08-4dab-9424-e8c1d5d5e30c",
"name": "Create a post",
"type": "n8n-nodes-base.linkedIn",
"position": [
1952,
1248
],
"parameters": {
"additionalFields": {}
},
"typeVersion": 1
},
{
"id": "d1b3ba59-e6be-4cc2-8e44-afc780d75596",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
480,
928
],
"parameters": {
"color": 2,
"width": 1696,
"height": 1040,
"content": "## Generate LinkedIn Post using LinkedIn Post Vector Store"
},
"typeVersion": 1
},
{
"id": "fdfec6f9-d470-4664-b840-c55aad0a2fa5",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-432,
208
],
"parameters": {
"width": 848,
"height": 2272,
"content": "# LinkedIn Post Generator with Viral Content Vector Database\n\n## Overview\nAI-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.\n\n**Key Capabilities:**\n- Scrapes LinkedIn post content via Telegram bot\n- Stores posts in Supabase vector database with OpenAI embeddings\n- 3-agent system analyzes hooks, structures outlines, and generates posts\n- RAG integration retrieves similar viral posts for pattern matching\n- Auto-publishes to LinkedIn or provides formatted output\n\n---\n\n# How It Works\n\n## Module 1: Viral Post Collection (Telegram Bot)\n\n**Step 1: URL Validation**\n- User sends LinkedIn post URL to Telegram bot\n- Workflow validates URL contains \"linkedin.com\"\n- Shows typing indicator for better UX\n\n**Step 2: Content Scraping**\n- HTTP request fetches post HTML\n- CSS selector extracts main commentary: `[data-test-id=\"main-feed-activity-card__commentary\"]`\n- Handles scraping failures with error messages\n\n**Step 3: Vector Storage**\n- Converts post text to OpenAI embeddings (text-embedding-ada-002)\n- Stores in Supabase `linkedin_post` table with vector indexing\n- Sends success confirmation via Telegram\n\n## Module 2: AI Post Generation (Web Form)\n\n**Stage 1: Hook Analysis Agent**\n- **Input**: User-provided hook text\n- **Process**: AI extracts topic, niche/industry, emotional tone, and 3-5 key points\n- **Output**: Structured JSON with analyzed elements\n- **Models**: GPT-4o-mini or Gemini 2.5-flash (dual fallback)\n\n**Stage 2: Post Structure Agent**\n- **Input**: Analyzed hook data\n- **Process**: Creates 5-section outline (Hook, Problem, Value/Lesson, Solution, CTA)\n- **Output**: Structured framework for final post\n- **Models**: GPT-4o-mini or Gemini 2.5-flash\n\n**Stage 3: Post Generator Agent (RAG)**\n- **Input**: Post structure + topic\n- **RAG Process**:\n - Queries Supabase vector store for 5 most similar viral posts\n - Analyzes patterns: hooks, storytelling, CTAs, engagement metrics\n - Identifies optimal length, formatting, and emotional triggers\n- **Output**: Complete LinkedIn post applying viral patterns\n- **Models**: GPT-4o-mini or Gemini 2.5-flash with GPT-5-NANO for structured output\n\n**Stage 4: Publication**\n- Auto-publishes to LinkedIn via API\n- Or returns formatted post text for manual posting\n\n---\n\n# How To Use\n\n## Setup\n\n### 1. Configure Supabase Vector Database\n- Create Supabase project\n- Create table: `linkedin_post` with vector column (1536 dimensions for OpenAI embeddings)\n- Enable vector extension: `CREATE EXTENSION vector;`\n- Update credentials in \"Upload Document\" and \"Supabase Vector Store\" nodes\n\n### 2. Set Up Telegram Bot (Module 1)\n- Create bot via [@BotFather](https://t.me/BotFather)\n- Get bot token and update \"On Telegram Message\" credentials\n- Start bot and get your chat ID\n- Activate workflow\n\n### 3. Configure OpenAI API\n- Add API key to \"Embeddings\" nodes (both modules)\n- Configure language model credentials (GPT-4o-mini, GPT-5-NANO)\n\n### 4. Set Up LinkedIn API (Optional for Module 2)\n- Create LinkedIn app with member permissions\n- Configure OAuth2 credentials in \"Create a post\" node\n- Or remove node to get text output only\n\n### 5. Access Web Form\n- Get form URL from \"LinkedIn Form\" webhook\n- Bookmark for easy access\n\n"
},
"typeVersion": 1
}
],
"connections": {
"If": {
"main": [
[
{
"node": "LinkedIn Post URL",
"type": "main",
"index": 0
}
],
[
{
"node": "Wrong URL",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "\u2705 Post Scrapped Sucessfully",
"type": "main",
"index": 0
}
]
]
},
"5 nano": {
"ai_languageModel": [
[
{
"node": "Structured Output Parser",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Structured Output Parser.",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Structured Output Parser1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"4o mini": {
"ai_languageModel": [
[
{
"node": "Hook Analyse Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Post Structure Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Post Generator Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"2.5-flash": {
"ai_languageModel": [
[
{
"node": "Hook Analyse Agent",
"type": "ai_languageModel",
"index": 1
},
{
"node": "Post Structure Agent",
"type": "ai_languageModel",
"index": 1
},
{
"node": "Post Generator Agent",
"type": "ai_languageModel",
"index": 1
}
]
]
},
"Embeddings": {
"ai_embedding": [
[
{
"node": "Upload Document",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Data Loader": {
"ai_document": [
[
{
"node": "Upload Document",
"type": "ai_document",
"index": 0
}
]
]
},
"Embeddings.": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"LinkedIn Form": {
"main": [
[
{
"node": "Hook Analyse Agent",
"type": "main",
"index": 0
}
]
]
},
"Scrap Content": {
"main": [
[
{
"node": "Upload Document",
"type": "main",
"index": 0
}
]
]
},
"Upload Document": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"LinkedIn Post URL": {
"main": [
[
{
"node": "Scrap Content",
"type": "main",
"index": 0
}
],
[
{
"node": "Unable to Scrape",
"type": "main",
"index": 0
}
]
]
},
"Hook Analyse Agent": {
"main": [
[
{
"node": "Post Structure Agent",
"type": "main",
"index": 0
}
]
]
},
"On Telegram Message": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
},
{
"node": "Typing....",
"type": "main",
"index": 0
}
]
]
},
"Post Generator Agent": {
"main": [
[
{
"node": "Create a post",
"type": "main",
"index": 0
}
]
]
},
"Post Structure Agent": {
"main": [
[
{
"node": "Post Generator Agent",
"type": "main",
"index": 0
}
]
]
},
"Supabase Vector Store": {
"ai_tool": [
[
{
"node": "Post Generator Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Hook Analyse Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Structured Output Parser.": {
"ai_outputParser": [
[
{
"node": "Post Structure Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "Post Generator Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApisupabaseApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
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…
Source: https://n8n.io/workflows/11385/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Inquiry-Agent. Uses @digitalocean/n8n-nodes-digitalocean-gradient-serverless-inference, stopAndError, googleDocs, gmail. Event-driven trigger; 88 nodes.
A lightweight, self-hosted AI assistant built entirely in n8n. Multi-channel messaging (Telegram, WhatsApp, Gmail), persistent memory, task management, and autonomous work — all in a single visual wor
Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.
Your AI workforce is ready. Are you?
Inquiry-Agent. Uses @digitalocean/n8n-nodes-digitalocean-gradient-serverless-inference, stopAndError, googleDocs, gmail. Event-driven trigger; 80 nodes.