MinAI - Về trang chủ
Lý thuyết
8/1335 phút
Đang tải...

Blog Post Generator

Xây dựng pipeline tự động tạo blog posts với AI trong n8n

✍️ Blog Post Generator

0

🎯 Mục tiêu bài học

TB5 min

Sau bài học này, bạn sẽ:

✅ Xây dựng multi-step blog generation pipeline

✅ Tạo outline từ topic với AI

✅ Viết sections tuần tự với Loop node

✅ Polish content và SEO optimize trước khi publish

Build automated pipeline: keyword/topic đầu vào, blog post hoàn chỉnh đầu ra. Multi-step AI workflow.

1

🏗️ Pipeline Architecture

TB5 min
Diagram
Đang vẽ diagram...

Checkpoint

Blog generation pipeline gồm những bước chính nào?

2

📝 Step 1: Topic to Outline

TB5 min
JavaScript
1// OpenAI Node 1: Generate Outline
2const outlinePrompt = `
3Create a detailed blog post outline for the topic: "${$json.topic}"
4
5Target audience: ${$json.audience || "tech professionals"}
6Tone: ${$json.tone || "professional yet approachable"}
7Word count target: ${$json.wordCount || 1500}
8
9Return JSON:
10{
11 "title": "SEO-optimized title",
12 "metaDescription": "155 chars max",
13 "sections": [
14 {
15 "heading": "H2 heading",
16 "subHeadings": ["H3 sub-heading 1", "..."],
17 "keyPoints": ["point 1", "point 2"],
18 "estimatedWords": 300
19 }
20 ],
21 "suggestedTags": ["tag1", "tag2"]
22}`;

Checkpoint

Outline prompt yêu cầu AI trả về những thông tin gì?

3

🔄 Step 2: Section-by-Section Writing

TB5 min
Diagram
Đang vẽ diagram...
JavaScript
1// Code node: Prepare section prompts
2const outline = JSON.parse($json.message.content);
3const sections = outline.sections;
4
5// Create items for Loop node
6return sections.map((section, index) => ({
7 json: {
8 sectionIndex: index,
9 heading: section.heading,
10 subHeadings: section.subHeadings,
11 keyPoints: section.keyPoints,
12 totalSections: sections.length,
13 topic: $json.topic,
14 tone: $json.tone || "professional"
15 }
16}));
JavaScript
1// OpenAI Node 2: Write each section (inside Loop)
2const writePrompt = `
3Write section ${$json.sectionIndex + 1} of ${$json.totalSections}
4for a blog post about "${$json.topic}".
5
6Section heading: ${$json.heading}
7Sub-headings: ${$json.subHeadings.join(", ")}
8Key points to cover: ${$json.keyPoints.join("; ")}
9Tone: ${$json.tone}
10
11Write engaging, informative content. Include:
12- Clear explanations
13- Practical examples where relevant
14- Smooth transitions
15- About ${$json.estimatedWords || 300} words
16
17Return the section content in Markdown format.`;

Checkpoint

Loop node đóng vai trò gì trong section-by-section writing?

4

✨ Step 3: Edit and Polish

TB5 min
JavaScript
1// OpenAI Node 3: Edit full draft
2const editPrompt = `
3You are a professional editor. Review and improve this blog post draft:
4
5${$json.fullDraft}
6
7Tasks:
81. Fix any grammar or spelling errors
92. Improve flow between sections
103. Ensure consistent tone throughout
114. Add engaging intro and conclusion
125. Improve readability (short paragraphs, varied sentence length)
13
14Return the polished version in Markdown.`;

Checkpoint

AI Editor thực hiện những task cải thiện nào cho draft?

5

🔍 Step 4: SEO Optimization

TB5 min
JavaScript
1// OpenAI Node 4: SEO optimize
2const seoPrompt = `
3Optimize this blog post for SEO:
4
5Title: ${$json.title}
6Content: ${$json.content}
7
8Return JSON:
9{
10 "optimizedTitle": "SEO title (50-60 chars)",
11 "metaDescription": "Meta description (150-155 chars)",
12 "slug": "url-friendly-slug",
13 "focusKeyword": "main keyword",
14 "tags": ["tag1", "tag2", "tag3"],
15 "internalLinkSuggestions": ["related topic 1", "related topic 2"]
16}`;

Checkpoint

SEO optimization step trả về những thông tin gì?

6

🚀 Step 5: Publish

TB5 min
JavaScript
1// WordPress node or HTTP Request node
2// POST to WordPress REST API
3const publishData = {
4 title: $json.seoData.optimizedTitle,
5 content: $json.polishedContent,
6 status: $json.autoPublish ? "publish" : "draft",
7 slug: $json.seoData.slug,
8 meta: {
9 description: $json.seoData.metaDescription
10 },
11 tags: $json.seoData.tags
12};
13
14return publishData;

Checkpoint

Khi nào nên auto-publish và khi nào nên save as draft?

7

🏗️ Full Workflow Example

TB5 min
Diagram
Đang vẽ diagram...
Cost Estimate

Mỗi blog post (1500 words) tốn khoảng 2000-3000 input tokens + 2000 output tokens qua 4 AI steps. Với GPT-4o-mini, chi phí khoảng $0.002 per post.

Checkpoint

Chi phí ước tính để generate một blog post 1500 words là bao nhiêu?

8

📝 Bài Tập Thực Hành

TB5 min
Exercises
  1. Build outline generator — input topic, output structured outline
  2. Add section-by-section writing với Loop node
  3. Implement edit step với grammar and style checks
  4. Connect to WordPress hoặc save as Google Doc

Checkpoint

Bạn đã hoàn thành blog pipeline chưa? Test với topic nào?

🚀 Bài tiếp theo

Social Media Content — Tự động tạo content cho nhiều social media platforms.