🎬 Generate knowledge base articles with GPT & Perplexity AI for Contentful CMS

⚑ 5,906 views · 🎬 Content Creation & Video

Description

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

flowchart LR
  A[Webhook: Chat Trigger] --> B[AI Writer Agent]
  B --> C[HTTP Request: Perplexity Content]
  C --> D[Function: Format Output & Citations]
  D --> E[Loop Start: Initialize Count]
  E --> F[AI Editor Agent]
  F --> G{action == "rewrite"?}
  G -- yes --> H[Function: Merge Improvements]
  H --> I[Increment Count] --> F
  G -- no --> J[Stop Loop]
  J --> K[HTTP 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:

{
  "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:

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:

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.

πŸ”— Nodes Used

Function, HTTP Request, Execute Sub-workflow, AI Agent, OpenAI Chat Model, Call n8n Workflow Tool

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup