AI Content Generation Services
Build AI-powered content generation services that automatically create blog posts, documentation, marketing copy, technical writing, and more using the Services-as-Software framework.
AI content generation services automate the creation of various types of written content, from blog posts and documentation to marketing copy and technical specifications. These services leverage advanced language models to produce high-quality, contextually appropriate content at scale.
Overview
Content generation services transform input requirements (topics, keywords, tone, audience) into polished written content. They can be monetized through per-word, per-article, or subscription pricing models and are ideal for businesses that need consistent, high-quality content production.
Key Benefits
- Scalability: Generate unlimited content without hiring additional writers
- Consistency: Maintain consistent tone, style, and quality across all content
- Speed: Produce content in minutes instead of hours or days
- Cost-Effective: Significantly lower cost per word compared to human writers
- Versatility: Support multiple content types and formats
- Optimization: Automatically include SEO optimization and metadata
Service Architecture
Content generation services typically follow this pattern:
- Input Processing: Parse and validate content requirements
- Context Building: Gather relevant information and examples
- Content Generation: Use AI models to create the content
- Quality Assurance: Validate readability, uniqueness, and adherence to requirements
- Enhancement: Add SEO metadata, formatting, and supplementary elements
- Delivery: Package and deliver the final content
Blog Post Generation Service
Create a comprehensive blog post generation service with SEO optimization:
import $, { ai, db, on, send } from 'sdk.do'
// Define the blog post generation service
const blogPostService = await $.Service.create({
id: 'blog-post-generator',
name: 'AI Blog Post Writer',
description: 'Generate SEO-optimized blog posts on any topic',
type: $.ServiceType.ContentGeneration,
subtype: 'blog-posts',
capabilities: ['long-form-content', 'seo-optimization', 'keyword-integration', 'image-suggestions', 'meta-generation'],
pricing: {
model: 'per-word',
baseRate: 0.05, // $0.05 per word
minimumCharge: 50.0, // Minimum $50 per article
tiers: [
{ wordCount: { min: 0, max: 1000 }, rate: 0.05 },
{ wordCount: { min: 1001, max: 2500 }, rate: 0.04 },
{ wordCount: { min: 2501, max: Infinity }, rate: 0.03 },
],
qualityModifiers: {
standard: 1.0,
premium: 1.5, // +50% for human review
urgent: 2.0, // +100% for 1-hour delivery
},
},
inputSchema: {
topic: { type: 'string', required: true },
keywords: { type: 'array', items: { type: 'string' }, required: true },
wordCount: { type: 'number', default: 1500, min: 500, max: 5000 },
tone: {
type: 'string',
enum: ['professional', 'casual', 'technical', 'conversational', 'formal'],
default: 'professional',
},
audience: {
type: 'string',
enum: ['general', 'technical', 'business', 'academic'],
default: 'general',
},
includeImages: { type: 'boolean', default: true },
quality: {
type: 'string',
enum: ['standard', 'premium', 'urgent'],
default: 'standard',
},
},
outputSchema: {
content: { type: 'string' },
title: { type: 'string' },
excerpt: { type: 'string' },
wordCount: { type: 'number' },
seo: {
type: 'object',
properties: {
metaDescription: { type: 'string' },
metaKeywords: { type: 'array' },
ogTitle: { type: 'string' },
ogDescription: { type: 'string' },
},
},
images: {
type: 'array',
items: {
type: 'object',
properties: {
position: { type: 'number' },
caption: { type: 'string' },
altText: { type: 'string' },
searchQuery: { type: 'string' },
},
},
},
readabilityScore: { type: 'number' },
uniquenessScore: { type: 'number' },
},
})
// Handle blog post generation requests
on($.ServiceRequest.created, async (request) => {
if (request.serviceId !== blogPostService.id) return
try {
// Update request status
await send($.ServiceRequest.update, {
requestId: request.id,
status: 'processing',
progress: 0.1,
})
// Research the topic to build context
const research = await ai.generate({
model: 'gpt-5',
prompt: `Research the topic "${request.inputs.topic}" and provide:
1. Key facts and statistics
2. Current trends and developments
3. Common questions and pain points
4. Expert perspectives
5. Related subtopics
Keywords to incorporate: ${request.inputs.keywords.join(', ')}`,
maxTokens: 1500,
})
await send($.ServiceRequest.update, {
requestId: request.id,
progress: 0.3,
})
// Generate the outline
const outline = await ai.generate({
model: 'gpt-5',
prompt: `Create a detailed outline for a ${request.inputs.wordCount}-word blog post about "${request.inputs.topic}".
Context: ${research.text}
Requirements:
- Tone: ${request.inputs.tone}
- Audience: ${request.inputs.audience}
- Keywords: ${request.inputs.keywords.join(', ')}
Include:
- Compelling headline
- Introduction (hook + thesis)
- 3-5 main sections with subheadings
- Conclusion with call-to-action
- Suggested image placements`,
maxTokens: 1000,
})
await send($.ServiceRequest.update, {
requestId: request.id,
progress: 0.5,
})
// Generate the full article
const article = await ai.generate({
model: 'gpt-5',
prompt: `Write a complete ${request.inputs.wordCount}-word blog post following this outline:
${outline.text}
Research context: ${research.text}
Guidelines:
- Tone: ${request.inputs.tone}
- Target audience: ${request.inputs.audience}
- Naturally incorporate keywords: ${request.inputs.keywords.join(', ')}
- Use examples and data where appropriate
- Include transitions between sections
- Write in an engaging, scannable format
- End with a strong conclusion and clear call-to-action`,
maxTokens: request.inputs.wordCount * 2,
temperature: 0.7,
quality: {
minReadability: request.inputs.audience === 'technical' ? 50 : 60,
keywordDensity: { min: 0.01, max: 0.03 },
uniqueness: 0.95,
},
})
await send($.ServiceRequest.update, {
requestId: request.id,
progress: 0.7,
})
// Generate SEO metadata
const seo = await ai.generate({
model: 'gpt-5',
prompt: `Generate SEO metadata for this blog post:
Title: ${outline.text.split('\n')[0]}
Content preview: ${article.text.substring(0, 500)}...
Keywords: ${request.inputs.keywords.join(', ')}
Provide:
1. Meta description (150-160 characters)
2. Meta keywords (5-10 keywords)
3. Open Graph title (60 characters max)
4. Open Graph description (200 characters max)`,
schema: {
metaDescription: { type: 'string' },
metaKeywords: { type: 'array', items: { type: 'string' } },
ogTitle: { type: 'string' },
ogDescription: { type: 'string' },
},
})
// Generate image suggestions if requested
let images = []
if (request.inputs.includeImages) {
const imagePrompt = await ai.generate({
model: 'gpt-5',
prompt: `Based on this blog post outline, suggest 3-5 relevant images:
${outline.text}
For each image, provide:
- Position in article (paragraph number)
- Caption
- Alt text for accessibility
- Image search query
Format as JSON array.`,
schema: {
images: {
type: 'array',
items: {
type: 'object',
properties: {
position: { type: 'number' },
caption: { type: 'string' },
altText: { type: 'string' },
searchQuery: { type: 'string' },
},
},
},
},
})
images = imagePrompt.data.images
}
await send($.ServiceRequest.update, {
requestId: request.id,
progress: 0.9,
})
// Extract title and create excerpt
const lines = article.text.split('\n').filter((line) => line.trim())
const title = lines[0].replace(/^#\s*/, '')
const excerpt = lines.slice(1, 3).join(' ').substring(0, 200) + '...'
// Calculate metrics
const wordCount = article.text.split(/\s+/).length
const readabilityScore = calculateReadability(article.text)
const uniquenessScore = 0.98 // Would integrate with plagiarism checker
// Deliver the completed blog post
await send($.ServiceResult.deliver, {
requestId: request.id,
outputs: {
content: article.text,
title,
excerpt,
wordCount,
seo: seo.data,
images,
readabilityScore,
uniquenessScore,
},
format: 'markdown',
quality: {
readability: readabilityScore,
uniqueness: uniquenessScore,
},
})
// Calculate cost based on word count and quality tier
const tier = blogPostService.pricing.tiers.find((t) => wordCount >= t.wordCount.min && wordCount <= t.wordCount.max)
const baseRate = tier?.rate || blogPostService.pricing.baseRate
const qualityMultiplier = blogPostService.pricing.qualityModifiers[request.inputs.quality] || 1.0
const cost = Math.max(wordCount * baseRate * qualityMultiplier, blogPostService.pricing.minimumCharge)
// Process payment
await send($.Payment.charge, {
customerId: request.customerId,
amount: cost,
description: `Blog Post: "${title}" (${wordCount} words)`,
metadata: {
serviceId: blogPostService.id,
requestId: request.id,
wordCount,
quality: request.inputs.quality,
},
})
// Update service analytics
await db.update(blogPostService, {
'metrics.totalPosts': { increment: 1 },
'metrics.totalWords': { increment: wordCount },
'metrics.totalRevenue': { increment: cost },
'metrics.avgReadability': { average: readabilityScore },
})
} catch (error) {
await send($.ServiceRequest.fail, {
requestId: request.id,
error: {
code: 'GENERATION_FAILED',
message: error.message,
details: error,
},
})
}
})
// Helper function to calculate readability score
function calculateReadability(text: string): number {
const sentences = text.split(/[.!?]+/).length
const words = text.split(/\s+/).length
const syllables = words * 1.5 // Approximation
// Flesch Reading Ease
const score = 206.835 - 1.015 * (words / sentences) - 84.6 * (syllables / words)
return Math.max(0, Math.min(100, score))
}Technical Documentation Service
Generate comprehensive technical documentation with code examples:
import $, { ai, db, on, send } from 'sdk.do'
const technicalDocsService = await $.Service.create({
id: 'technical-docs-generator',
name: 'Technical Documentation Writer',
description: 'Generate API docs, user guides, and technical specifications',
type: $.ServiceType.ContentGeneration,
subtype: 'technical-documentation',
pricing: {
model: 'per-document',
rates: {
apiDocs: 200.0,
userGuide: 150.0,
technicalSpec: 300.0,
tutorial: 100.0,
},
},
})
on($.ServiceRequest.created, async (request) => {
if (request.serviceId !== technicalDocsService.id) return
const { documentType, codebase, apiSpec, targetAudience } = request.inputs
// Analyze codebase or API specification
const analysis = await ai.generate({
model: 'gpt-5',
prompt: `Analyze this ${documentType} specification and extract:
- Key components and their purposes
- API endpoints or functions
- Parameters and return values
- Common use cases
- Error scenarios
Specification: ${apiSpec || codebase}`,
maxTokens: 2000,
})
// Generate documentation structure
const structure = await ai.generate({
model: 'gpt-5',
prompt: `Create a documentation outline for ${documentType}:
Analysis: ${analysis.text}
Target audience: ${targetAudience}
Include:
- Overview and introduction
- Getting started guide
- Detailed reference sections
- Code examples
- Best practices
- Troubleshooting`,
maxTokens: 1500,
})
// Generate each section with code examples
const sections = await Promise.all(
extractSections(structure.text).map(async (section) => {
const content = await ai.generate({
model: 'gpt-5',
prompt: `Write the "${section.title}" section of the ${documentType} documentation.
Context: ${analysis.text}
Audience: ${targetAudience}
Include:
- Clear explanations
- Code examples in multiple languages
- Parameter descriptions
- Response examples
- Common pitfalls and solutions`,
maxTokens: 3000,
})
return {
title: section.title,
content: content.text,
level: section.level,
}
})
)
// Compile complete documentation
const documentation = {
title: `${documentType} Documentation`,
sections,
format: 'markdown',
tableOfContents: generateTOC(sections),
lastUpdated: new Date().toISOString(),
}
await send($.ServiceResult.deliver, {
requestId: request.id,
outputs: { documentation },
})
const cost = technicalDocsService.pricing.rates[documentType] || 200
await send($.Payment.charge, {
customerId: request.customerId,
amount: cost,
description: `Technical Documentation: ${documentType}`,
})
})
function extractSections(outline: string) {
return outline
.split('\n')
.filter((line) => line.match(/^#+\s/))
.map((line) => ({
title: line.replace(/^#+\s*/, ''),
level: (line.match(/^#+/) || [''])[0].length,
}))
}
function generateTOC(sections: any[]) {
return sections.map((s) => ({
title: s.title,
level: s.level,
anchor: s.title.toLowerCase().replace(/\s+/g, '-'),
}))
}Marketing Copy Service
Create persuasive marketing content for various channels:
import $, { ai, on, send } from 'sdk.do'
const marketingCopyService = await $.Service.create({
id: 'marketing-copy-generator',
name: 'Marketing Copy Writer',
description: 'Generate ads, landing pages, emails, and social media content',
type: $.ServiceType.ContentGeneration,
subtype: 'marketing-copy',
pricing: {
model: 'per-piece',
rates: {
adCopy: 50.0,
landingPage: 200.0,
emailCampaign: 100.0,
socialPost: 25.0,
productDescription: 30.0,
},
packages: [
{
name: 'Social Media Bundle',
includes: ['10 social posts', '5 ad copies'],
price: 200.0,
savings: 50.0,
},
{
name: 'Launch Campaign',
includes: ['1 landing page', '5 emails', '20 social posts', '10 ads'],
price: 800.0,
savings: 250.0,
},
],
},
})
on($.ServiceRequest.created, async (request) => {
if (request.serviceId !== marketingCopyService.id) return
const { contentType, product, audience, platform, tone, callToAction } = request.inputs
// Analyze product and competitive landscape
const productAnalysis = await ai.generate({
model: 'gpt-5',
prompt: `Analyze this product for marketing purposes:
Product: ${product.name}
Description: ${product.description}
Features: ${product.features.join(', ')}
Benefits: ${product.benefits.join(', ')}
Target audience: ${audience}
Identify:
- Unique value propositions
- Key differentiators
- Emotional triggers
- Pain points addressed
- Competitive advantages`,
maxTokens: 1000,
})
let copy: string
switch (contentType) {
case 'adCopy':
copy = await generateAdCopy({
product,
audience,
platform,
tone,
callToAction,
analysis: productAnalysis.text,
})
break
case 'landingPage':
copy = await generateLandingPage({
product,
audience,
tone,
analysis: productAnalysis.text,
})
break
case 'emailCampaign':
copy = await generateEmailCampaign({
product,
audience,
campaignType: request.inputs.campaignType,
analysis: productAnalysis.text,
})
break
case 'socialPost':
copy = await generateSocialPost({
product,
platform,
tone,
analysis: productAnalysis.text,
})
break
case 'productDescription':
copy = await generateProductDescription({
product,
tone,
analysis: productAnalysis.text,
})
break
}
// A/B test variations
const variations = await ai.generate({
model: 'gpt-5',
prompt: `Create 2 alternative versions of this ${contentType}:
Original: ${copy}
For each variation:
- Maintain the core message
- Try different emotional appeals
- Use different headline structures
- Test different CTAs`,
maxTokens: 2000,
})
await send($.ServiceResult.deliver, {
requestId: request.id,
outputs: {
primaryCopy: copy,
variations: parseVariations(variations.text),
metadata: {
wordCount: copy.split(/\s+/).length,
characterCount: copy.length,
readingTime: estimateReadingTime(copy),
sentiment: 'positive',
cta: callToAction,
},
},
})
const cost = marketingCopyService.pricing.rates[contentType]
await send($.Payment.charge, {
customerId: request.customerId,
amount: cost,
description: `Marketing Copy: ${contentType}`,
})
})
async function generateAdCopy(params: any): Promise<string> {
const result = await ai.generate({
model: 'gpt-5',
prompt: `Write compelling ad copy for ${params.platform}:
Product: ${params.product.name}
Analysis: ${params.analysis}
Audience: ${params.audience}
Tone: ${params.tone}
Platform specs:
${getplatformSpecs(params.platform)}
Include:
- Attention-grabbing headline
- Clear value proposition
- Strong ${params.callToAction}
- Urgency or scarcity element`,
maxTokens: 500,
})
return result.text
}
async function generateLandingPage(params: any): Promise<string> {
const result = await ai.generate({
model: 'gpt-5',
prompt: `Create landing page copy with high conversion focus:
Product: ${params.product.name}
Analysis: ${params.analysis}
Audience: ${params.audience}
Structure:
1. Hero section (headline + subheadline)
2. Value propositions (3-4 key benefits)
3. Feature highlights with descriptions
4. Social proof section
5. FAQ section
6. Final CTA section
Tone: ${params.tone}
Focus on conversion and trust-building.`,
maxTokens: 3000,
})
return result.text
}
async function generateEmailCampaign(params: any): Promise<string> {
const result = await ai.generate({
model: 'gpt-5',
prompt: `Write email campaign copy:
Product: ${params.product.name}
Campaign type: ${params.campaignType}
Analysis: ${params.analysis}
Audience: ${params.audience}
Include:
- Compelling subject line (+ 2 alternatives)
- Preview text
- Email body (personalized greeting, value prop, details, CTA)
- P.S. with additional incentive
Keep it conversational and benefit-focused.`,
maxTokens: 1500,
})
return result.text
}
function getplatformSpecs(platform: string) {
const specs = {
facebook: 'Headline: 40 chars, Text: 125 chars, Link description: 30 chars',
google: 'Headlines: 30 chars (3), Descriptions: 90 chars (2)',
linkedin: 'Headline: 200 chars, Text: 600 chars',
instagram: 'Caption: 2200 chars (but 125 visible), Hashtags: 30 max',
}
return specs[platform] || 'Standard format'
}
function parseVariations(text: string): string[] {
return text
.split(/Variation \d+:/)
.slice(1)
.map((v) => v.trim())
}
function estimateReadingTime(text: string): number {
const words = text.split(/\s+/).length
return Math.ceil(words / 200) // 200 words per minute
}Product Description Service
Generate compelling e-commerce product descriptions:
import $, { ai, on, send } from 'sdk.do'
const productDescriptionService = await $.Service.create({
id: 'product-description-generator',
name: 'E-commerce Description Writer',
description: 'Generate SEO-optimized product descriptions for online stores',
type: $.ServiceType.ContentGeneration,
subtype: 'product-descriptions',
pricing: {
model: 'per-product',
tiers: [
{ name: 'basic', price: 10.0, features: ['Short description', 'Bullet points'] },
{ name: 'standard', price: 25.0, features: ['Long description', 'SEO', 'Features'] },
{ name: 'premium', price: 50.0, features: ['All standard', 'A/B variations', 'Multi-channel'] },
],
bulk: [
{ min: 10, max: 49, discount: 0.1 },
{ min: 50, max: 99, discount: 0.2 },
{ min: 100, max: Infinity, discount: 0.3 },
],
},
})
on($.ServiceRequest.created, async (request) => {
if (request.serviceId !== productDescriptionService.id) return
const { products, tier, includeVariations } = request.inputs
const results = []
for (const product of products) {
// Generate product description based on tier
const description = await ai.generate({
model: 'gpt-5',
prompt: `Write an engaging e-commerce product description:
Product: ${product.name}
Category: ${product.category}
Features: ${product.features.join(', ')}
Specifications: ${JSON.stringify(product.specs)}
Target customer: ${product.targetAudience}
Price: $${product.price}
Include:
- Compelling opening sentence
- Key benefits (not just features)
- Use case scenarios
- Quality and value statements
- Urgency or scarcity elements
Tone: Persuasive but authentic
Length: ${tier === 'basic' ? '100-150' : tier === 'standard' ? '200-300' : '300-500'} words`,
maxTokens: 1000,
})
// Generate bullet points
const bullets = await ai.generate({
model: 'gpt-5',
prompt: `Create 5-8 compelling bullet points for this product:
${description.text}
Focus on benefits over features.
Start each with an action verb or benefit statement.`,
maxTokens: 300,
})
// Generate SEO elements if standard or premium
let seo = null
if (tier !== 'basic') {
seo = await ai.generate({
model: 'gpt-5',
prompt: `Generate SEO elements for this product:
${description.text}
Provide:
- Meta title (60 chars)
- Meta description (155 chars)
- Keywords (10-15)
- Alt text for product image`,
schema: {
metaTitle: { type: 'string' },
metaDescription: { type: 'string' },
keywords: { type: 'array', items: { type: 'string' } },
altText: { type: 'string' },
},
})
}
// Generate variations if premium
let variations = []
if (tier === 'premium' && includeVariations) {
const varResult = await ai.generate({
model: 'gpt-5',
prompt: `Create 2 alternative versions of this product description for A/B testing:
Original: ${description.text}
Variation 1: Focus on emotional benefits
Variation 2: Focus on practical advantages`,
maxTokens: 1500,
})
variations = parseVariations(varResult.text)
}
results.push({
productId: product.id,
productName: product.name,
description: description.text,
bullets: parseBullets(bullets.text),
seo: seo?.data || null,
variations,
wordCount: description.text.split(/\s+/).length,
})
}
await send($.ServiceResult.deliver, {
requestId: request.id,
outputs: { products: results },
})
// Calculate cost with bulk discount
const productCount = products.length
const basePrice = productDescriptionService.pricing.tiers.find((t) => t.name === tier)?.price || 10
const bulkTier = productDescriptionService.pricing.bulk.find((b) => productCount >= b.min && productCount <= b.max)
const discount = bulkTier?.discount || 0
const totalCost = productCount * basePrice * (1 - discount)
await send($.Payment.charge, {
customerId: request.customerId,
amount: totalCost,
description: `Product Descriptions: ${productCount} products (${tier} tier)`,
metadata: {
productCount,
tier,
bulkDiscount: discount,
},
})
})
function parseBullets(text: string): string[] {
return text
.split('\n')
.filter((line) => line.match(/^[-*•]/))
.map((line) => line.replace(/^[-*•]\s*/, ''))
}Email Campaign Service
Generate complete email campaigns with sequences:
import $, { ai, on, send } from 'sdk.do'
const emailCampaignService = await $.Service.create({
id: 'email-campaign-generator',
name: 'Email Campaign Creator',
description: 'Generate email sequences for onboarding, nurture, and promotional campaigns',
type: $.ServiceType.ContentGeneration,
subtype: 'email-campaigns',
pricing: {
model: 'per-campaign',
baseRate: 150.0,
perEmail: 30.0,
campaignTypes: {
welcome: { emails: 3, price: 150 },
nurture: { emails: 5, price: 200 },
promotional: { emails: 3, price: 120 },
reengagement: { emails: 4, price: 150 },
abandoned: { emails: 3, price: 120 },
},
},
})
on($.ServiceRequest.created, async (request) => {
if (request.serviceId !== emailCampaignService.id) return
const { campaignType, product, audience, goals, brandVoice } = request.inputs
// Generate campaign strategy
const strategy = await ai.generate({
model: 'gpt-5',
prompt: `Create an email campaign strategy:
Type: ${campaignType}
Product/Service: ${product.name}
Target audience: ${audience}
Goals: ${goals.join(', ')}
Define:
- Campaign objective
- Email sequence (timing and purpose of each)
- Key messages for each email
- Conversion metrics`,
maxTokens: 1000,
})
// Generate each email in the sequence
const emails = await Promise.all(
Array.from({ length: getCampaignLength(campaignType) }).map(async (_, index) => {
const email = await ai.generate({
model: 'gpt-5',
prompt: `Write email ${index + 1} of the ${campaignType} campaign:
Strategy: ${strategy.text}
Product: ${product.name}
Brand voice: ${brandVoice}
Include:
- Subject line (3 variations)
- Preview text
- Email body (HTML-ready markdown)
- Clear CTA
- P.S. line
Email purpose: ${getEmailPurpose(campaignType, index)}`,
maxTokens: 1500,
})
return {
sequenceNumber: index + 1,
timing: getEmailTiming(campaignType, index),
subject: extractSubjectLines(email.text),
previewText: extractPreviewText(email.text),
body: extractBody(email.text),
cta: extractCTA(email.text),
}
})
)
await send($.ServiceResult.deliver, {
requestId: request.id,
outputs: {
campaign: {
type: campaignType,
strategy: strategy.text,
emails,
totalEmails: emails.length,
},
},
})
const pricing = emailCampaignService.pricing.campaignTypes[campaignType]
await send($.Payment.charge, {
customerId: request.customerId,
amount: pricing.price,
description: `Email Campaign: ${campaignType} (${pricing.emails} emails)`,
})
})
function getCampaignLength(type: string): number {
const lengths = {
welcome: 3,
nurture: 5,
promotional: 3,
reengagement: 4,
abandoned: 3,
}
return lengths[type] || 3
}
function getEmailPurpose(type: string, index: number): string {
const purposes = {
welcome: ['Welcome and set expectations', 'Provide value and resources', 'Encourage first action'],
nurture: ['Educate on problem', 'Present solution', 'Build trust', 'Handle objections', 'Convert to customer'],
promotional: ['Announce offer', 'Provide social proof', 'Create urgency'],
reengagement: ['Acknowledge absence', 'Show what they missed', 'Special comeback offer', 'Last chance'],
abandoned: ['Gentle reminder', 'Address concerns', 'Final incentive'],
}
return purposes[type]?.[index] || 'Engage and convert'
}
function getEmailTiming(type: string, index: number): string {
const timing = {
welcome: ['Immediately', 'Day 2', 'Day 7'],
nurture: ['Day 0', 'Day 3', 'Day 7', 'Day 14', 'Day 21'],
promotional: ['Day 0', 'Day 3', 'Day 6'],
reengagement: ['Day 0', 'Day 7', 'Day 14', 'Day 30'],
abandoned: ['1 hour', '24 hours', '3 days'],
}
return timing[type]?.[index] || `Email ${index + 1}`
}
function extractSubjectLines(text: string): string[] {
const match = text.match(/Subject.*?:(.*?)(?:\n|$)/i)
return match ? match[1].split(',').map((s) => s.trim()) : []
}
function extractPreviewText(text: string): string {
const match = text.match(/Preview.*?:(.*?)(?:\n|$)/i)
return match ? match[1].trim() : ''
}
function extractBody(text: string): string {
const bodyMatch = text.match(/Body:(.*?)(?:CTA:|$)/is)
return bodyMatch ? bodyMatch[1].trim() : text
}
function extractCTA(text: string): string {
const ctaMatch = text.match(/CTA:(.*?)(?:\n|$)/i)
return ctaMatch ? ctaMatch[1].trim() : ''
}Pricing Models
Content generation services support various pricing strategies:
Per-Word Pricing
Best for: Blog posts, articles, long-form content
const pricing = {
model: 'per-word',
baseRate: 0.05, // $0.05 per word
minimumCharge: 50.0,
tiers: [
{ wordCount: { min: 0, max: 1000 }, rate: 0.05 },
{ wordCount: { min: 1001, max: 2500 }, rate: 0.04 },
{ wordCount: { min: 2501, max: Infinity }, rate: 0.03 },
],
}Per-Piece Pricing
Best for: Marketing copy, product descriptions, emails
const pricing = {
model: 'per-piece',
rates: {
adCopy: 50.0,
landingPage: 200.0,
emailCampaign: 100.0,
socialPost: 25.0,
productDescription: 30.0,
},
}Subscription Pricing
Best for: Ongoing content needs, agency clients
const pricing = {
model: 'subscription',
tiers: [
{
name: 'starter',
price: 299,
includes: {
blogPosts: 4,
socialPosts: 20,
emails: 4,
},
},
{
name: 'professional',
price: 799,
includes: {
blogPosts: 12,
socialPosts: 60,
emails: 12,
productDescriptions: 50,
},
},
{
name: 'enterprise',
price: 1999,
includes: {
blogPosts: 30,
socialPosts: 150,
emails: 30,
productDescriptions: 200,
technicalDocs: 4,
},
},
],
}Quality Assurance
Ensure high-quality content generation:
interface QualityMetrics {
readability: number // Flesch Reading Ease score
uniqueness: number // Plagiarism check score
keywordDensity: number // Target keyword usage
sentiment: 'positive' | 'neutral' | 'negative'
grammarScore: number // Grammar check score
toneMatch: number // Alignment with requested tone
}
async function validateQuality(content: string, requirements: any): Promise<QualityMetrics> {
const metrics: QualityMetrics = {
readability: calculateReadability(content),
uniqueness: await checkUniqueness(content),
keywordDensity: calculateKeywordDensity(content, requirements.keywords),
sentiment: await analyzeSentiment(content),
grammarScore: await checkGrammar(content),
toneMatch: await matchTone(content, requirements.tone),
}
// Validate against minimums
if (metrics.readability < requirements.minReadability) {
throw new Error(`Readability score ${metrics.readability} below minimum ${requirements.minReadability}`)
}
if (metrics.uniqueness < 0.95) {
throw new Error(`Content uniqueness ${metrics.uniqueness} below required 95%`)
}
return metrics
}Best Practices
1. Context Building
Always research the topic before generating content:
// Bad: Direct generation
const content = await ai.generate({ prompt: topic })
// Good: Research-backed generation
const research = await ai.generate({ prompt: `Research ${topic}` })
const content = await ai.generate({
prompt: `Write about ${topic}`,
context: research.text,
})2. Iterative Refinement
Generate outlines before full content:
const outline = await ai.generate({ prompt: 'Create outline' })
const content = await ai.generate({
prompt: 'Write full content',
context: outline.text,
})3. Quality Validation
Always validate generated content:
const content = await ai.generate(options)
const quality = await validateQuality(content.text, requirements)
if (quality.readability < 60) {
content = await ai.generate({
...options,
prompt: options.prompt + '\nUse simpler language and shorter sentences.',
})
}4. SEO Optimization
Include SEO as a separate generation step:
const content = await ai.generate({ prompt: mainPrompt })
const seo = await ai.generate({
prompt: `Generate SEO metadata for: ${content.text}`,
schema: SEOSchema,
})Real-World Use Cases
Publishing Company
Generate 100+ blog posts per month across multiple topics:
- Challenge: Need consistent, high-quality content at scale
- Solution: Blog post generation service with quality tiers
- Result: 80% cost reduction, 5x increase in content output
E-commerce Store
Generate product descriptions for 10,000+ SKUs:
- Challenge: Time-consuming manual description writing
- Solution: Bulk product description service with SEO
- Result: Completed in 2 weeks vs. 6 months manual effort
Marketing Agency
Create campaign content for multiple clients:
- Challenge: Managing content across various brands and tones
- Solution: Multi-channel marketing copy service
- Result: 60% faster campaign launches, consistent brand voice
SaaS Company
Maintain up-to-date technical documentation:
- Challenge: Documentation always lagging behind product updates
- Solution: Auto-generated docs from API specifications
- Result: Always current documentation, 90% time savings
Related Resources
- AI Analysis Services - Extract insights from generated content
- Building Services Guide - Implementation details
- Pricing Models - Monetization strategies
- Quality Assurance Guide - Ensure content quality
- API Reference - Service API documentation
AI Analysis Services
Build AI-powered analysis services that extract insights from data, perform sentiment analysis, detect trends, identify anomalies, and provide predictive analytics using the Services-as-Software framework.
AI Creative Services
Build AI-powered creative services that generate designs, images, videos, music, brand assets, and visual content using the Services-as-Software framework.