by InlinexDev

Prompt Engineering for Automated Content Generation: What Actually Works

Practical prompt engineering techniques for generating SEO blog content with Gemini AI, based on running a daily content automation system.

AIprompt engineeringcontent generationGeminiSEO

Beyond Basic Prompts

After running an automated blog generation system for months, producing hundreds of articles with Gemini AI, here's what we learned about prompt engineering for content generation. The difference between a mediocre AI article and a genuinely useful one comes down to the prompt.

The Anatomy of an Effective Content Prompt

A good content generation prompt has five layers:

  1. Role definition — who is the AI writing as?
  2. Context — what does the AI need to know?
  3. Instructions — what exactly should it produce?
  4. Constraints — what should it avoid?
  5. Format — how should the output be structured?

Example: Blog Post Prompt

const prompt = `
ROLE: You are a technical writer for an inline skating equipment store. 
You have deep expertise in skating equipment, maintenance, and technique. 
Your tone is helpful, conversational, and authoritative.

CONTEXT:
- Store name: Inlinex
- Location: Singapore
- Target audience: Beginner to intermediate inline skaters
- Competitor articles on this topic: ${competitorSnippets}
- Previously published topics (DO NOT REPEAT): ${previousTopics}

TASK: Write a blog post about "${topic}"

REQUIREMENTS:
- 800-1200 words
- Start with a hook that addresses a common pain point
- Include at least 3 H2 subheadings
- Add practical, actionable tips (not generic advice)
- Reference specific products or equipment where natural
- End with a subtle call-to-action mentioning Inlinex
- Include a FAQ section with 3 questions

CONSTRAINTS:
- Do NOT use these overused phrases: "game-changer", "in conclusion", 
  "without further ado", "it's important to note"
- Do NOT make up statistics or studies
- Do NOT use more than one exclamation mark per paragraph
- Keep paragraphs under 4 sentences

FORMAT:
- Output in HTML
- Use <h2> for main sections, <h3> for subsections
- Use <ul> for lists
- Wrap the FAQ in a <div class="faq"> container
`;

Technique 1: Topic Differentiation

The biggest risk with AI content is generating the same article that already ranks. Our system researches competitors first:

async function buildDifferentiationContext(topic) {
  const searchResults = await googleSearch(topic);
  const topArticles = searchResults.slice(0, 5);
  
  const snippets = topArticles.map(article => 
    `- "${article.title}": ${article.snippet}`
  ).join('\n');
  
  return `
Existing articles on this topic:
${snippets}

Your article must cover angles NOT addressed in the above articles. 
Focus on unique insights, personal experience, and specific product recommendations.
`;
}

Technique 2: Previous Topic Tracking

Preventing repetition requires maintaining a topic registry:

async function getPublishedTopics() {
  const articles = await db.query(
    'SELECT title, main_topic, published_at FROM articles ORDER BY published_at DESC LIMIT 100'
  );
  
  return articles.rows.map(a => a.main_topic);
}

// In the prompt:
// "Previously covered topics: wheel hardness, bearing maintenance, 
//  skate sizing, helmet selection... Generate a DIFFERENT topic."

Technique 3: Quality Scoring

Not all generated content meets our standards. We score articles before publishing:

function scoreArticle(article) {
  let score = 0;
  
  // Length check
  const wordCount = article.split(/\s+/).length;
  if (wordCount >= 800 && wordCount <= 1200) score += 20;
  else if (wordCount >= 600) score += 10;
  
  // Structure check
  const h2Count = (article.match(/<h2/g) || []).length;
  if (h2Count >= 3) score += 20;
  
  // Actionable content check
  const actionPhrases = ['you can', 'try this', 'here\'s how', 'step 1', 'tip:'];
  const actionScore = actionPhrases.filter(p => 
    article.toLowerCase().includes(p)
  ).length;
  score += Math.min(actionScore * 5, 20);
  
  // Banned phrase check
  const bannedPhrases = ['game-changer', 'without further ado', 'in this article we will'];
  const hasBanned = bannedPhrases.some(p => article.toLowerCase().includes(p));
  if (!hasBanned) score += 20;
  
  // FAQ check
  if (article.includes('faq')) score += 20;
  
  return score; // Out of 100
}

Articles scoring below 60 are regenerated with an adjusted prompt.

Technique 4: Temperature and Parameter Tuning

Different content types need different generation parameters:

const CONTENT_CONFIGS = {
  'how-to-guide': {
    temperature: 0.3,  // Low creativity, high accuracy
    topP: 0.8
  },
  'opinion-piece': {
    temperature: 0.7,  // Higher creativity
    topP: 0.9
  },
  'product-comparison': {
    temperature: 0.2,  // Factual and precise
    topP: 0.7
  },
  'general-tips': {
    temperature: 0.5,  // Balanced
    topP: 0.85
  }
};

Technique 5: Iterative Refinement

For important content, use a two-pass approach:

async function generateRefinedArticle(topic) {
  // Pass 1: Generate draft
  const draft = await generateContent(topic, { temperature: 0.5 });
  
  // Pass 2: Refine with specific feedback
  const refinementPrompt = `
Review and improve this article:
${draft}

Specifically:
1. Replace any generic advice with specific, actionable tips
2. Add concrete examples or numbers where claims are vague
3. Ensure the introduction hooks the reader within 2 sentences
4. Check that each section delivers unique value
5. Tighten the conclusion to 2-3 sentences
`;
  
  const refined = await generateContent(refinementPrompt, { temperature: 0.3 });
  return refined;
}

What Doesn't Work

  • "Write a 1000-word SEO article about X" — too vague, produces generic content
  • Asking for specific word counts — AI models are bad at counting; use ranges
  • Over-constraining — too many rules produce stiff, unnatural writing
  • No context about the brand — the AI writes generic content without brand voice
  • Skipping quality checks — some outputs will be poor; always score and filter

Metrics After 3 Months

  • Articles published: 90
  • Average quality score: 78/100
  • Regeneration rate: 12% (articles that scored below threshold)
  • Organic traffic increase: 45%
  • Average time on page: 2.5 minutes (comparable to human-written content)
  • Monthly API cost: approximately $5

Conclusion

Prompt engineering for content generation is about specificity, context, and quality control. The prompt is only half the system — the other half is automated quality scoring, topic management, and iterative refinement. Treat AI content generation as a pipeline, not a single API call.

Related Project

AI-Powered Blog Automation

Daily SEO blog post generator that researches products with Google Search, writes authentic reviews using Gemini AI, and publishes directly to Shopify.