Generate knowledge base articles with GPT & Perplexity AI for Contentful CMS
Needs changesNeeds changes. This template uses 2 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes), Function (legacy). 2 breaking item(s) found. Static check, last run 2026-10-19.
What to replace before upgrading
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) AI Writer Agent (v1.7), AI Editor Agent (v1.7) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
| Function (legacy) Increment Count | Code node, mode 'Run Once for All Items' |
Nodes used (12)
- HTTP Request
n8n-nodes-base.httpRequest - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Call n8n Workflow Tool
@n8n/n8n-nodes-langchain.toolWorkflow - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Code
n8n-nodes-base.code - Merge
n8n-nodes-base.merge - Edit Fields (Set)
n8n-nodes-base.set - Function
n8n-nodes-base.function - If
n8n-nodes-base.if - No Operation, do nothing
n8n-nodes-base.noOp - Execute Sub-workflow
n8n-nodes-base.executeWorkflow
What it does
Workflow: Auto Knowledge Base Article Generator ⚡ About the Creators This workflow was created by Varritech Technologies, an innovative agency that leverages AI to engineer, design, and deliver software development projects 500% faster than traditional agencies. Based in New York City, we specialize in custom software development, web applications, and digital transformation solutions. If you need assistance implementing this workflow or have questions about content management solutions, please reach out to our team. 🏗️ Architecture Overview This workflow automates the end-to-end creation of a structured knowledge-base article from a simple chat prompt: 1. Chat Trigger → Receives user request 2. AI Drafting Loop → Generates & refines JSON article via AI agents 3. Perplexity Research Call → Deep-dive content generation 4. Editorial Loop → Up to 3 AI-driven revisions 5. Contentful Publish → Pushes final JSON into CMS --- 📦 Node-by-Node Breakdown mermaid flowchart LR AWebhook: Chat Trigger --> BAI Writer Agent B --> CHTTP Request: Perplexity Content C --> DFunction: Format Output & Citations D --> ELoop Start: Initialize Count E --> FAI Editor Agent F --> G{action == "rewrite"?} G -- yes --> HFunction: Merge Improvements H --> IIncrement Count --> F G -- no --> JStop Loop J --> KHTTP Request: Publish to Contentful Webhook: Chat Trigger Type: HTTP Webhook (POST /webhook/knowledge-article) Payload: { "chatInput": "What topics should I write about?" } Purpose: Kicks off the workflow on that chat prompt. AI Writer Agent Inputs: chatInput or existing article JSON Outputs: { "title": "...", "slug": "...", "category.id": "...", "description": "...", "keywords": ..., "content": "...", "metaTitle": "...", "metaDescription": "...", "readingTime": 5, "difficulty": "intermediate" } Purpose: Generates the article skeleton (metadata + initial content). HTTP Request: Perplexity Content Method: POST URL: https://api.perplexity.ai/research Body: json { "model": "sonar-deep-research", "query": "{{ $json.title }}", "length": 1000 } Purpose: Retrieves a long-form, deeply researched draft for the article body. Function: Format Output & Citations Logic: - Parse raw Perplexity response - Extract source URIs - Append them under a sources markdown list Editorial Loop 1. Initialize Counter to 0 2. AI Editor Agent - Reads draft JSON - Returns either: - action: "rewrite" + improvements: ... - or action: "submit" 3. Merge Improvements (if rewriting) - Applies suggested updates to JSON fields 4. Limit Check - Stops after 3 iterations or on "submit" HTTP Request: Publish to Contentful Method: PUT URL: https://cdn.contentful.com/spaces/{space}/environments/master/entries/{entryId} Headers: - Authorization: Bearer <token> - Content-Type: application/vnd.contentful.management.v1+json Body: Maps JSON → Contentful entry fields Outcome: Publishes the finalized article live. 🔍 Design Rationale & Best Practices Separation of Concerns Writer vs. Editor agents isolate creative drafting from quality review. Idempotent Loop Counter + action flags prevent infinite retries. Extensibility Swap in different research APIs or CMS targets with minimal changes. Structured JSON Ensures predictable input/output for each node.