Skip to main content

Workflow 2: Content Generation

This workflow generates content using AI models based on input data and templates.

Overview

The Content Generation workflow creates high-quality content using AI models. It supports various content types including articles, summaries, and marketing copy.

Workflow Steps

Step 1: Content Planning

Purpose: Analyzes requirements and creates content plan

Configuration:

{
"stepId": "content_planning",
"name": "Content Planning",
"type": "ai-process",
"config": {
"model": "gpt-4",
"prompt": "Create a content plan for:",
"outputFormat": "structured"
}
}

Step 2: Content Generation

Purpose: Generates content based on plan

Configuration:

{
"stepId": "content_generation",
"name": "Content Generation",
"type": "ai-process",
"config": {
"model": "gpt-4",
"temperature": 0.8,
"maxTokens": 2000
}
}

Step 3: Content Review

Purpose: Reviews and validates generated content

Configuration:

{
"stepId": "content_review",
"name": "Content Review",
"type": "validation",
"config": {
"qualityThreshold": 0.8,
"checkGrammar": true,
"checkTone": true
}
}

Step 4: Content Publishing

Purpose: Publishes content to target platforms

Configuration:

{
"stepId": "content_publishing",
"name": "Content Publishing",
"type": "output",
"config": {
"platforms": ["cms", "blog", "social"],
"format": "markdown"
}
}

Configuration

Basic Configuration

{
"name": "Content Generation Workflow",
"description": "Generates content using AI",
"timeout": 120000,
"retries": 2
}

Usage Examples

Generate Article

import { AIWorkflow } from 'ai-workflow';

const workflow = new AIWorkflow({
apiKey: process.env.AI_WORKFLOW_API_KEY
});

const result = await workflow.execute('content-generation-workflow', {
input: {
topic: "AI in Healthcare",
type: "article",
length: "long",
tone: "professional"
}
});

console.log('Generated content:', result.content);

Generate Multiple Variations

const variations = await Promise.all([
workflow.execute('content-generation-workflow', {
input: { topic: "AI", tone: "professional" }
}),
workflow.execute('content-generation-workflow', {
input: { topic: "AI", tone: "casual" }
}),
workflow.execute('content-generation-workflow', {
input: { topic: "AI", tone: "technical" }
})
]);

Input/Output

Input Schema

{
"topic": "string",
"type": "string (article|summary|copy)",
"length": "string (short|medium|long)",
"tone": "string (professional|casual|technical)",
"targetAudience": "string",
"keywords": "array"
}

Output Schema

{
"content": "string",
"metadata": {
"wordCount": "number",
"readabilityScore": "number",
"generatedAt": "timestamp"
},
"variations": "array"
}

Error Handling

Common Errors

Error CodeDescriptionSolution
INVALID_TOPICTopic is too vague or invalidProvide more specific topic
CONTENT_QUALITY_LOWGenerated content doesn't meet quality thresholdAdjust quality settings
MODEL_OVERLOADAI model is overloadedRetry with backoff

Best Practices

  1. Provide clear and specific topics
  2. Use appropriate tone for target audience
  3. Review generated content before publishing
  4. Test with different variations
  5. Monitor content quality metrics

Next Steps