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

Social Media Automation

Automate social media với n8n - Multi-platform posting, scheduling, engagement tracking

📱 Social Media Automation

Social Media Automation

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 cross-platform posting workflow

✅ Implement content scheduling và optimal time calculator

✅ Tạo engagement auto-responder với sentiment classification

✅ Thiết kế social listening dashboard và content repurposing

Manage your social presence efficiently. Bài này hướng dẫn automate posting, scheduling, và monitoring across multiple platforms.

1

🔍 Social Media Automation Strategy

TB5 min

Automation Opportunities:

📱Social Media Automation Map
📤Publishing
🔄Cross-platform posting
📅Content scheduling
🖼️Image/video upload
🧵Thread publishing
📊Monitoring
🔔Mention tracking
#️⃣Hashtag monitoring
🕵️Competitor tracking
🧠Sentiment analysis
📈Analytics
💬Engagement metrics
📊Growth tracking
Best time analysis
🏆Content performance
💬Engagement
🤖Auto-responses
✉️DM management
🛡️Comment moderation
🎯Lead capture

Checkpoint

Có mấy loại social media tasks có thể automate?

2

⚡ Workflow 1: Cross-Platform Posting

TB5 min

Post to Multiple Platforms:

Multi-Platform Publisher

📋Trigger: New Row / Scheduled Post
📝Parse Content & Media
🐦Post to Twitter/X
💼Post to LinkedIn
📘Post to Facebook
📸Post to Instagram
📊Log Results to Spreadsheet
🚨Notify if Any Failures

Content Adapter:

JavaScript
1const originalPost = $input.item.json;
2
3// Platform-specific character limits
4const limits = {
5 twitter: 280,
6 linkedin: 3000,
7 facebook: 63206,
8 instagram: 2200
9};
10
11// Platform-specific formatting
12function adaptForPlatform(content, platform, hashtags = []) {
13 let adapted = content;
14 const limit = limits[platform];
15
16 // Add hashtags
17 const hashtagString = hashtags.map(h => `#${h}`).join(' ');
18
19 switch (platform) {
20 case 'twitter':
21 // Shorten and add hashtags
22 const hashtagSpace = hashtagString.length + 1;
23 if (content.length + hashtagSpace > limit) {
24 adapted = content.substring(0, limit - hashtagSpace - 3) + '...';
25 }
26 adapted = `${adapted} ${hashtagString}`;
27 break;
28
29 case 'linkedin':
30 // Professional formatting
31 adapted = `${content}\n\n${hashtagString}\n\n---\n💡 What are your thoughts?`;
32 break;
33
34 case 'facebook':
35 // Casual formatting
36 adapted = `${content}\n\n${hashtagString}`;
37 break;
38
39 case 'instagram':
40 // Visual-first formatting
41 adapted = `${content}\n\n.\n.\n.\n${hashtagString}`;
42 break;
43 }
44
45 return adapted.substring(0, limit);
46}
47
48const platforms = ['twitter', 'linkedin', 'facebook', 'instagram'];
49const results = platforms.map(platform => ({
50 platform,
51 content: adaptForPlatform(
52 originalPost.text,
53 platform,
54 originalPost.hashtags || []
55 ),
56 mediaUrl: originalPost.imageUrl,
57 scheduledFor: originalPost.scheduledTime
58}));
59
60return results;

Checkpoint

Cross-platform posting adapt content cho mấy platforms?

3

🔧 Workflow 2: Content Scheduling System

TB5 min

Buffer-Like Scheduler:

Content Queue Manager

Schedule: Every 15 min
🔗Webhook: Add to Queue
📋Check Scheduled Posts Queue
🧮Calculate Optimal Time
🚀Due Now → Publish
⏭️Not Due → Skip
📅Add to Schedule
Update Status & Log Results

Optimal Time Calculator:

JavaScript
1const post = $input.item.json;
2const platform = post.platform;
3
4// Best posting times by platform (in UTC)
5const bestTimes = {
6 twitter: {
7 weekday: [9, 12, 15, 18], // 9am, 12pm, 3pm, 6pm
8 weekend: [10, 14, 18]
9 },
10 linkedin: {
11 weekday: [8, 12, 17], // Work hours
12 weekend: [10, 14]
13 },
14 facebook: {
15 weekday: [13, 16, 20], // Afternoon/evening
16 weekend: [12, 15, 19]
17 },
18 instagram: {
19 weekday: [7, 12, 19, 21], // Early, lunch, evening
20 weekend: [10, 14, 18, 21]
21 }
22};
23
24// Find next available optimal slot
25function getNextOptimalTime(platform, timezone = 'Asia/Ho_Chi_Minh') {
26 const now = new Date();
27 const times = bestTimes[platform] || bestTimes.twitter;
28
29 const isWeekend = now.getDay() === 0 || now.getDay() === 6;
30 const optimalHours = isWeekend ? times.weekend : times.weekday;
31
32 // Find next available slot (at least 30 min from now)
33 const minTime = new Date(now.getTime() + 30 * 60 * 1000);
34
35 for (let dayOffset = 0; dayOffset < 7; dayOffset++) {
36 const checkDate = new Date(now);
37 checkDate.setDate(checkDate.getDate() + dayOffset);
38
39 const dayIsWeekend = checkDate.getDay() === 0 || checkDate.getDay() === 6;
40 const hours = dayIsWeekend ? times.weekend : times.weekday;
41
42 for (const hour of hours) {
43 const slotTime = new Date(checkDate);
44 slotTime.setHours(hour, 0, 0, 0);
45
46 if (slotTime > minTime) {
47 return slotTime.toISOString();
48 }
49 }
50 }
51
52 return minTime.toISOString();
53}
54
55return {
56 ...post,
57 scheduledFor: post.scheduledFor || getNextOptimalTime(platform),
58 autoScheduled: !post.scheduledFor
59};

Checkpoint

Content scheduling tính optimal posting time bằng cách nào?

4

🏗️ Workflow 3: Twitter/X Thread Publisher

TB5 min

Publish Long-Form Content as Thread:

Twitter Thread Publisher

🏷️Trigger: Long Content with 'thread' Tag
✂️Split into Tweets (max 280 chars)
🔢Add Thread Numbering
🐦Post First Tweet
🔁Loop: Reply to Previous Tweet
Complete Thread
🔗Notify with Thread URL

Thread Splitter:

JavaScript
1const content = $input.item.json.content;
2const maxLength = 270; // Leave room for numbering
3
4// Smart split - prefer breaking at sentences/paragraphs
5function smartSplit(text, maxLen) {
6 const tweets = [];
7 let remaining = text.trim();
8
9 while (remaining.length > 0) {
10 if (remaining.length <= maxLen) {
11 tweets.push(remaining);
12 break;
13 }
14
15 // Try to split at paragraph
16 let splitPoint = remaining.lastIndexOf('\n\n', maxLen);
17
18 // Try to split at sentence
19 if (splitPoint === -1 || splitPoint < maxLen / 2) {
20 splitPoint = remaining.lastIndexOf('. ', maxLen);
21 if (splitPoint > 0) splitPoint += 1; // Include the period
22 }
23
24 // Try to split at any space
25 if (splitPoint === -1 || splitPoint < maxLen / 2) {
26 splitPoint = remaining.lastIndexOf(' ', maxLen);
27 }
28
29 // Force split if needed
30 if (splitPoint === -1 || splitPoint < maxLen / 2) {
31 splitPoint = maxLen;
32 }
33
34 tweets.push(remaining.substring(0, splitPoint).trim());
35 remaining = remaining.substring(splitPoint).trim();
36 }
37
38 return tweets;
39}
40
41const tweets = smartSplit(content, maxLength);
42
43// Add numbering
44const numberedTweets = tweets.map((tweet, index) => {
45 const number = `${index + 1}/${tweets.length}`;
46 const isLast = index === tweets.length - 1;
47
48 return {
49 index,
50 text: isLast ? `${tweet}\n\n[END THREAD 🧵]` : `${tweet}\n\n${number}`,
51 isFirst: index === 0,
52 isLast
53 };
54});
55
56return { tweets: numberedTweets, totalTweets: tweets.length };

Checkpoint

Twitter thread publisher split content thành tweets dựa trên logic gì?

5

📊 Workflow 4: Engagement Auto-Responder

TB5 min

Auto-Respond to Mentions:

Mention Responder

Schedule: Every 30 min
🔍Fetch Recent Mentions
🔀Filter: Not Already Responded
Question → AI Answer & Reply
👍Positive → Like & Thank
⚠️Complaint → Flag for Human
🚫Spam → Ignore/Block

Mention Classifier:

JavaScript
1const mention = $input.item.json;
2const text = mention.text.toLowerCase();
3
4// Classification rules
5const patterns = {
6 question: [
7 /\?$/,
8 /how (do|can|to)/i,
9 /what (is|are)/i,
10 /why (is|are|do)/i,
11 /can you/i,
12 /help/i
13 ],
14 positive: [
15 /thank/i,
16 /love/i,
17 /great/i,
18 /awesome/i,
19 /amazing/i,
20 /|||/
21 ],
22 complaint: [
23 /not working/i,
24 /broken/i,
25 /bug/i,
26 /issue/i,
27 /problem/i,
28 /terrible/i,
29 /worst/i
30 ],
31 spam: [
32 /buy followers/i,
33 /free.*followers/i,
34 /dm for/i,
35 /check.*bio/i,
36 /giveaway/i
37 ]
38};
39
40function classify(text) {
41 for (const [category, regexes] of Object.entries(patterns)) {
42 for (const regex of regexes) {
43 if (regex.test(text)) {
44 return category;
45 }
46 }
47 }
48 return 'neutral';
49}
50
51const classification = classify(text);
52
53// Determine response strategy
54let action, template;
55switch (classification) {
56 case 'question':
57 action = 'ai_respond';
58 template = null; // Let AI generate
59 break;
60
61 case 'positive':
62 action = 'thank';
63 template = [
64 'Thank you so much! 🙏',
65 'We appreciate the kind words! ❤️',
66 'Glad you like it! 🎉',
67 'Thanks for the support! 💪'
68 ];
69 break;
70
71 case 'complaint':
72 action = 'escalate';
73 template = "Sorry to hear that! Please DM us with more details and we'll help resolve this ASAP. 🙏";
74 break;
75
76 case 'spam':
77 action = 'ignore';
78 template = null;
79 break;
80
81 default:
82 action = 'like_only';
83 template = null;
84}
85
86return {
87 ...mention,
88 classification,
89 action,
90 template: Array.isArray(template)
91 ? template[Math.floor(Math.random() * template.length)]
92 : template
93};

Checkpoint

Engagement auto-responder classify mentions thành mấy categories?

6

💡 Workflow 5: Social Listening Dashboard

TB5 min

Monitor Brand & Keywords:

Social Listening

Schedule: Every Hour
🐦Search Twitter for Brand
💼Search LinkedIn for Keywords
🟠Check Reddit Mentions
📰Monitor News Articles
📦Aggregate Results
🧠Sentiment Analysis
📊Update Dashboard (Notion/Airtable)
🚨Slack Alert (Negative Spike)
📧Email Report (Daily Summary)

Sentiment Analysis:

JavaScript
1const mentions = $input.all();
2
3// Simple sentiment scoring
4const positiveWords = ['love', 'great', 'awesome', 'amazing', 'excellent', 'fantastic', 'thank', 'recommend', 'best', 'perfect'];
5const negativeWords = ['hate', 'terrible', 'awful', 'worst', 'disappointed', 'broken', 'bug', 'issue', 'bad', 'poor', 'fail'];
6
7function analyzeSentiment(text) {
8 const lower = text.toLowerCase();
9 let score = 0;
10
11 for (const word of positiveWords) {
12 if (lower.includes(word)) score += 1;
13 }
14
15 for (const word of negativeWords) {
16 if (lower.includes(word)) score -= 1;
17 }
18
19 if (score > 0) return { sentiment: 'positive', score };
20 if (score < 0) return { sentiment: 'negative', score };
21 return { sentiment: 'neutral', score: 0 };
22}
23
24// Process all mentions
25const results = mentions.map(mention => {
26 const analysis = analyzeSentiment(mention.json.text);
27 return {
28 ...mention.json,
29 ...analysis,
30 analyzedAt: new Date().toISOString()
31 };
32});
33
34// Calculate summary stats
35const stats = {
36 total: results.length,
37 positive: results.filter(r => r.sentiment === 'positive').length,
38 negative: results.filter(r => r.sentiment === 'negative').length,
39 neutral: results.filter(r => r.sentiment === 'neutral').length,
40 avgScore: results.reduce((sum, r) => sum + r.score, 0) / results.length
41};
42
43// Alert threshold
44const negativeRatio = stats.negative / stats.total;
45const needsAlert = negativeRatio > 0.3 || stats.negative >= 10;
46
47return {
48 mentions: results,
49 stats,
50 needsAlert,
51 alertReason: needsAlert
52 ? `High negative mention rate: ${Math.round(negativeRatio * 100)}% (${stats.negative}/${stats.total})`
53 : null
54};

Checkpoint

Social listening dashboard phân tích sentiment bằng cách nào?

7

🌟 Workflow 6: Content Repurposing

TB5 min

Repurpose Across Platforms:

Content Repurposer

📝New Blog Post Published
🔑Extract Key Points & Quotes
🐦Create Twitter Thread
💼Create LinkedIn Post
📸Create Instagram Carousel
📧Create Email Newsletter Snippet
📄Create LinkedIn Article
📅Schedule All Versions
📊Track Which Performed Best

Content Repurposer:

JavaScript
1const blogPost = $input.item.json;
2
3// Generate different content formats
4const repurposed = {
5 original: {
6 title: blogPost.title,
7 url: blogPost.url,
8 publishedAt: blogPost.publishedAt
9 },
10
11 // Twitter thread version
12 twitterThread: `🧵 Thread: ${blogPost.title}
13
14${blogPost.summary}
15
16Here are the key takeaways:
17
18${blogPost.keyPoints.map((point, i) => `${i + 1}. ${point}`).join('\n\n')}
19
20Read the full post: ${blogPost.url}
21
22What's your take? 👇`,
23
24 // LinkedIn professional post
25 linkedIn: `📝 ${blogPost.title}
26
27${blogPost.summary}
28
29Key insights:
30
31${blogPost.keyPoints.map(point => `✅ ${point}`).join('\n')}
32
33${blogPost.hashtags.map(h => `#${h}`).join(' ')}
34
35Full article in comments `,
36
37 // Instagram caption (visual focus)
38 instagram: `${blogPost.title} 📌
39
40${blogPost.summary}
41
42Swipe through for the key insights!
43
44.
45.
46.
47
48${blogPost.hashtags.slice(0, 30).map(h => `#${h}`).join(' ')}`,
49
50 // Email newsletter snippet
51 emailSnippet: `
52<h3>${blogPost.title}</h3>
53<p>${blogPost.summary}</p>
54<ul>
55${blogPost.keyPoints.map(point => `<li>${point}</li>`).join('\n')}
56</ul>
57<a href="${blogPost.url}">Read more </a>
58`,
59
60 // Quote graphics text
61 quoteGraphics: blogPost.quotableLines.map(quote => ({
62 text: `"${quote}"`,
63 attribution: blogPost.author,
64 style: 'quote_card'
65 }))
66};
67
68return { repurposed };

Checkpoint

Content repurposer tạo bao nhiêu versions từ một blog post?

8

🔧 Platform Integration Tips

TB5 min
Platform-Specific Notes

Twitter/X:

  • Use API v2 for new features
  • Rate limits: 50 tweets/24h (free), 1500/month (basic)
  • Thread posting requires reply-to previous tweet ID

LinkedIn:

  • API requires approved application
  • Rich media needs pre-upload
  • Company pages vs personal profiles have different endpoints

Facebook:

  • Pages API more flexible than personal
  • Meta Business Suite for business accounts
  • Webhook for real-time updates

Instagram:

  • Business/Creator accounts only via API
  • No direct message automation (officially)
  • Stories automation limited

Checkpoint

Rate limit cho Twitter API free tier là bao nhiêu?

9

📋 Best Practices

TB5 min
Social Automation Guidelines

DO:

  • ✅ Maintain authentic voice
  • ✅ Respond personally to meaningful interactions
  • ✅ Test content before scheduling
  • ✅ Monitor automation results
  • ✅ Respect platform rate limits

DON'T:

  • ❌ Auto-DM new followers
  • ❌ Mass-follow/unfollow
  • ❌ Post identical content everywhere
  • ❌ Automate all engagement
  • ❌ Ignore platform ToS

Checkpoint

Tại sao không nên auto-DM new followers?

10

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

TB5 min
Social Media Challenge

Build your social automation:

  1. Set up cross-platform posting workflow
  2. Implement content scheduling queue
  3. Add engagement auto-responder
  4. Create social listening alerts
  5. Build content repurposing pipeline

Amplify your reach! 📱

Checkpoint

Bạn đã hoàn thành những challenges nào trong bài tập?

11

🧠 Key Takeaways

TB5 min
Remember
  • 🎯 Adapt content - Each platform has its culture
  • Time strategically - Post when audience is active
  • 🤖 Balance automation - Keep human touch
  • 📊 Track performance - Learn what works
  • ⚠️ Respect limits - Don't get banned!

Checkpoint

Tại sao cần adapt content for each platform?

🚀 Bài tiếp theo

Lead Generation — Automate lead capture và nurturing workflows.