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

Content Writing Automation

Tự động hóa viết content với LLMs - blog, email, social media, product descriptions

0

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

TB5 min

Tự động hóa content writing là ứng dụng phổ biến nhất của LLMs trong business. Bài này hướng dẫn build các content generation pipelines chuyên nghiệp.

Sau bài này, bạn sẽ:

✅ Build content generation pipelines cho blog, email, social media ✅ Tạo multi-step pipeline với outline và full write ✅ Implement content repurposing từ một source sang nhiều formats ✅ Áp dụng best practices cho content automation trong production

1

🔍 Content Generation Architecture

TB5 min
Diagram
Đang vẽ diagram...

Checkpoint

Bạn đã hiểu kiến trúc tổng quát của content generation pipeline chưa?

2

💻 Blog Post Generator

TB5 min

Multi-step Pipeline

python.py
1from langchain_openai import ChatOpenAI
2from langchain_core.prompts import ChatPromptTemplate
3from langchain_core.output_parsers import StrOutputParser
4
5llm = ChatOpenAI(model="gpt-4o-mini", temperature=0.7)
6
7# Step 1: Generate outline
8outline_template = ChatPromptTemplate.from_messages([
9 ("system", """Ban la content strategist. Tao outline cho blog post voi:
10 - Hook introduction
11 - 4-5 main sections voi headings
12 - Key points cho moi section
13 - Conclusion voi CTA"""),
14 ("human", "Topic: {topic}\nAudience: {audience}\nTone: {tone}")
15])
16
17# Step 2: Write full post
18write_template = ChatPromptTemplate.from_messages([
19 ("system", """Ban la content writer chuyen nghiep.
20 Viet blog post day du tu outline.
21 Su dung tone {tone}, do dai khoang {word_count} tu.
22 Format voi Markdown headings."""),
23 ("human", "Outline:\n{outline}\n\nViet bai hoan chinh:")
24])
25
26# Build chains
27outline_chain = outline_template | llm | StrOutputParser()
28write_chain = write_template | llm | StrOutputParser()
29
30# Execute
31outline = outline_chain.invoke({
32 "topic": "AI trong Marketing 2025",
33 "audience": "marketing managers",
34 "tone": "professional"
35})
36
37blog_post = write_chain.invoke({
38 "outline": outline,
39 "tone": "professional",
40 "word_count": "1000"
41})
42print(blog_post)

Checkpoint

Bạn đã hiểu cách build multi-step blog post generator chưa?

3

💻 Email Template Generator

TB5 min
python.py
1from pydantic import BaseModel, Field
2from typing import List
3
4class EmailOutput(BaseModel):
5 subject: str = Field(description="Email subject line")
6 greeting: str = Field(description="Opening greeting")
7 body: str = Field(description="Main email body")
8 closing: str = Field(description="Closing and signature")
9
10email_template = ChatPromptTemplate.from_messages([
11 ("system", """Ban la email copywriter. Viet email {email_type}.
12 Tone: {tone}
13 Keep it concise and professional."""),
14 ("human", "Viet email cho {recipient} ve: {topic}")
15])
16
17structured_llm = llm.with_structured_output(EmailOutput)
18email_chain = email_template | structured_llm
19
20email = email_chain.invoke({
21 "email_type": "follow-up",
22 "tone": "friendly professional",
23 "recipient": "potential client",
24 "topic": "demo AI product"
25})
26
27print(f"Subject: {email.subject}")
28print(f"\n{email.greeting}\n\n{email.body}\n\n{email.closing}")

Checkpoint

Bạn đã hiểu cách tạo email generator với structured output chưa?

4

💻 Social Media Content

TB5 min

Multi-platform Generator

python.py
1class SocialPost(BaseModel):
2 platform: str
3 content: str
4 hashtags: List[str]
5 character_count: int
6
7class SocialPack(BaseModel):
8 posts: List[SocialPost]
9
10social_template = ChatPromptTemplate.from_messages([
11 ("system", """Tao social media content pack tu blog post.
12 Tao 1 post cho moi platform:
13 - LinkedIn (professional, 200-300 words)
14 - Twitter/X (concise, max 280 chars)
15 - Facebook (engaging, 100-200 words)
16 - Instagram caption (visual, include emojis)"""),
17 ("human", "Blog post:\n{blog_content}")
18])
19
20social_chain = social_template | llm.with_structured_output(SocialPack)
21
22pack = social_chain.invoke({"blog_content": blog_post})
23for post in pack.posts:
24 print(f"\n--- {post.platform} ---")
25 print(post.content)
26 print(f"Hashtags: {', '.join(post.hashtags)}")

Checkpoint

Bạn đã hiểu cách tạo content pack cho nhiều social media platforms chưa?

5

💻 Product Description Writer

TB5 min
python.py
1product_template = ChatPromptTemplate.from_messages([
2 ("system", """Ban la e-commerce copywriter.
3 Viet product description voi:
4 - Headline hap dan
5 - Key features (bullet points)
6 - Benefits (customer-focused)
7 - Technical specs
8 Tone: {tone}
9 Length: {length} tu"""),
10 ("human", """Product: {product_name}
11Category: {category}
12Features: {features}
13Target audience: {target}""")
14])
15
16product_chain = product_template | llm | StrOutputParser()
17
18description = product_chain.invoke({
19 "tone": "persuasive",
20 "length": "200",
21 "product_name": "Smart AI Assistant Pro",
22 "category": "Software",
23 "features": "voice control, task automation, calendar management",
24 "target": "busy professionals"
25})

Checkpoint

Bạn đã hiểu cách tạo product description writer chưa?

6

⚡ Content Repurposing Pipeline

TB5 min
Diagram
Đang vẽ diagram...
python.py
1from langchain_core.runnables import RunnableParallel
2
3# Parallel repurposing
4repurpose = RunnableParallel(
5 twitter=twitter_chain,
6 linkedin=linkedin_chain,
7 email=email_chain,
8 video_script=script_chain
9)
10
11results = repurpose.invoke({"content": blog_post})

Checkpoint

Bạn đã hiểu cách build content repurposing pipeline với RunnableParallel chưa?

7

🎯 Tổng kết

TB5 min
Content Automation Tips
  1. Brand voice consistency: Dùng system prompt để set brand guidelines
  2. Human review: AI tạo draft, người review và chỉnh sửa
  3. A/B testing: Tạo nhiều versions để test
  4. Template library: Lưu các prompt templates hiệu quả
  5. Quality checks: Validate output trước khi publish
Lưu ý
  • Luôn review AI-generated content trước khi publish
  • Avoid plagiarism - check originality
  • Maintain factual accuracy
  • Respect copyright và brand guidelines
Hands-on Exercise

Build Content Pipeline:

  1. Tạo blog post generator với outline + full write
  2. Build email template generator với structured output
  3. Tạo social media repurposing pipeline
  4. Add quality check step (readability, tone)

Bonus: Implement content calendar automation

Câu hỏi tự kiểm tra

  1. Pipeline content writing automation thường bao gồm những bước chính nào?
  2. Tại sao cần sử dụng system prompt để đảm bảo brand voice consistency trong content generation?
  3. Content repurposing pipeline hoạt động như thế nào khi chuyển blog post sang nhiều format khác nhau?
  4. Tại sao human review vẫn cần thiết khi sử dụng AI để tạo content tự động?

🎉 Tuyệt vời! Bạn đã hoàn thành bài học Content Writing Automation!

Tiếp theo: Hãy đi sâu hơn vào LangChain framework với bài LangChain Deep Dive!


🚀 Bài tiếp theo

LangChain Deep Dive cho Text →