🎬 Convert Markdown content to Contentful rich text with AI formatting

898 views · 🎬 Content Creation & Video

Description

Workflow: Publish to Contentful with Rich Text Formatting

⚡ 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 takes a JSON article payload, splits its markdown content into logical chunks, converts each chunk into Contentful Rich Text JSON via an AI agent, merges the resulting rich text nodes back into a single document, formats the entire entry according to Contentful’s field schema, and finally publishes it to Contentful.

  1. Trigger → Executes when called by another workflow
  2. Split by Headings → Breaks markdown into ##-delimited chunks
  3. Markdown → Rich Text → AI agent converts each chunk to Contentful Rich Text JSON
  4. Combine Rich Text Objects → Aggregates all chunk outputs into one document
  5. Format Entry → Wraps metadata and rich-text content into Contentful schema
  6. Publish Entry → HTTP POST to Contentful API

📦 Node-by-Node Breakdown

flowchart LR
  A[When Executed by Another Workflow] --> B[Split by Headings]
  B --> C[Markdown to Contentful format]
  C --> D[Combine Rich Text Objects]
  D --> E[Merge1]
  E --> F[Format1]
  F --> G[Create newly formatted Contentful Entry]

1. When Executed by Another Workflow

Type: Execute Workflow Trigger

Input Example:

Purpose: Receives the JSON payload from the upstream workflow.

2. Split by Headings

Type: Code

Logic:

3. Markdown to Contentful format

Type: LangChain Agent (+ OpenAI Chat model)

System Prompt:

User Prompt:

Here is the markdown content to convert: {{ $json.contentChunk }}

Purpose: Converts each markdown chunk into an array of rich-text nodes.

4. Combine Rich Text Objects

Type: Code

Logic:

5. Merge1

Type: Merge

Purpose: Joins the original item (with metadata) and the combined rich-text document into a single data stream.

6. Format1

Type: Code

Logic:

7. Create newly formatted Contentful Entry

Type: HTTP Request

Method: POST

URL: https://api.contentful.com/spaces

Headers:

Body: The formatted fields object produced by the previous node

Purpose: Publishes the new entry with rich-text content to Contentful.

🔍 Design Rationale & Best Practices

Chunked Conversion

Splitting by headings prevents AI context limits and keeps conversions modular.

Strict Rich Text Schema

Enforcing nodeType, data, and content structure avoids validation errors on Contentful.

Two-Phase Merge

Separating “combine AI outputs” and “format entry” keeps transformations clear and testable.

Idempotent Publish

Uses explicit versioning and content type headers to ensure correct entry creation.

🔗 Nodes Used

HTTP Request, Execute Workflow Trigger, AI Agent, OpenAI Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup