📱 Social Media Automation
🎯 Mục tiêu bài học
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.
🔍 Social Media Automation Strategy
Automation Opportunities:
Checkpoint
Có mấy loại social media tasks có thể automate?
⚡ Workflow 1: Cross-Platform Posting
Post to Multiple Platforms:
Multi-Platform Publisher
Content Adapter:
1const originalPost = $input.item.json;23// Platform-specific character limits4const limits = {5 twitter: 280,6 linkedin: 3000,7 facebook: 63206,8 instagram: 22009};1011// Platform-specific formatting12function adaptForPlatform(content, platform, hashtags = []) {13 let adapted = content;14 const limit = limits[platform];15 16 // Add hashtags17 const hashtagString = hashtags.map(h => `#${h}`).join(' ');18 19 switch (platform) {20 case 'twitter':21 // Shorten and add hashtags22 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 formatting31 adapted = `${content}\n\n${hashtagString}\n\n---\n💡 What are your thoughts?`;32 break;33 34 case 'facebook':35 // Casual formatting36 adapted = `${content}\n\n${hashtagString}`;37 break;38 39 case 'instagram':40 // Visual-first formatting41 adapted = `${content}\n\n.\n.\n.\n${hashtagString}`;42 break;43 }44 45 return adapted.substring(0, limit);46}4748const 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.scheduledTime58}));5960return results;Checkpoint
Cross-platform posting adapt content cho mấy platforms?
🔧 Workflow 2: Content Scheduling System
Buffer-Like Scheduler:
Content Queue Manager
Optimal Time Calculator:
1const post = $input.item.json;2const platform = post.platform;34// Best posting times by platform (in UTC)5const bestTimes = {6 twitter: {7 weekday: [9, 12, 15, 18], // 9am, 12pm, 3pm, 6pm8 weekend: [10, 14, 18]9 },10 linkedin: {11 weekday: [8, 12, 17], // Work hours12 weekend: [10, 14]13 },14 facebook: {15 weekday: [13, 16, 20], // Afternoon/evening16 weekend: [12, 15, 19]17 },18 instagram: {19 weekday: [7, 12, 19, 21], // Early, lunch, evening20 weekend: [10, 14, 18, 21]21 }22};2324// Find next available optimal slot25function 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}5455return {56 ...post,57 scheduledFor: post.scheduledFor || getNextOptimalTime(platform),58 autoScheduled: !post.scheduledFor59};Checkpoint
Content scheduling tính optimal posting time bằng cách nào?
🏗️ Workflow 3: Twitter/X Thread Publisher
Publish Long-Form Content as Thread:
Twitter Thread Publisher
Thread Splitter:
1const content = $input.item.json.content;2const maxLength = 270; // Leave room for numbering34// Smart split - prefer breaking at sentences/paragraphs5function 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 paragraph16 let splitPoint = remaining.lastIndexOf('\n\n', maxLen);17 18 // Try to split at sentence19 if (splitPoint === -1 || splitPoint < maxLen / 2) {20 splitPoint = remaining.lastIndexOf('. ', maxLen);21 if (splitPoint > 0) splitPoint += 1; // Include the period22 }23 24 // Try to split at any space25 if (splitPoint === -1 || splitPoint < maxLen / 2) {26 splitPoint = remaining.lastIndexOf(' ', maxLen);27 }28 29 // Force split if needed30 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}4041const tweets = smartSplit(content, maxLength);4243// Add numbering44const 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 isLast53 };54});5556return { tweets: numberedTweets, totalTweets: tweets.length };Checkpoint
Twitter thread publisher split content thành tweets dựa trên logic gì?
📊 Workflow 4: Engagement Auto-Responder
Auto-Respond to Mentions:
Mention Responder
Mention Classifier:
1const mention = $input.item.json;2const text = mention.text.toLowerCase();34// Classification rules5const 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/i13 ],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/i30 ],31 spam: [32 /buy followers/i,33 /free.*followers/i,34 /dm for/i,35 /check.*bio/i,36 /giveaway/i37 ]38};3940function 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}5051const classification = classify(text);5253// Determine response strategy54let action, template;55switch (classification) {56 case 'question':57 action = 'ai_respond';58 template = null; // Let AI generate59 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}8586return {87 ...mention,88 classification,89 action,90 template: Array.isArray(template) 91 ? template[Math.floor(Math.random() * template.length)]92 : template93};Checkpoint
Engagement auto-responder classify mentions thành mấy categories?
💡 Workflow 5: Social Listening Dashboard
Monitor Brand & Keywords:
Social Listening
Sentiment Analysis:
1const mentions = $input.all();23// Simple sentiment scoring4const positiveWords = ['love', 'great', 'awesome', 'amazing', 'excellent', 'fantastic', 'thank', 'recommend', 'best', 'perfect'];5const negativeWords = ['hate', 'terrible', 'awful', 'worst', 'disappointed', 'broken', 'bug', 'issue', 'bad', 'poor', 'fail'];67function 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}2324// Process all mentions25const 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});3334// Calculate summary stats35const 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.length41};4243// Alert threshold44const negativeRatio = stats.negative / stats.total;45const needsAlert = negativeRatio > 0.3 || stats.negative >= 10;4647return {48 mentions: results,49 stats,50 needsAlert,51 alertReason: needsAlert 52 ? `High negative mention rate: ${Math.round(negativeRatio * 100)}% (${stats.negative}/${stats.total})`53 : null54};Checkpoint
Social listening dashboard phân tích sentiment bằng cách nào?
🌟 Workflow 6: Content Repurposing
Repurpose Across Platforms:
Content Repurposer
Content Repurposer:
1const blogPost = $input.item.json;23// Generate different content formats4const repurposed = {5 original: {6 title: blogPost.title,7 url: blogPost.url,8 publishedAt: blogPost.publishedAt9 },10 11 // Twitter thread version12 twitterThread: `🧵 Thread: ${blogPost.title}1314${blogPost.summary}1516Here are the key takeaways:1718${blogPost.keyPoints.map((point, i) => `${i + 1}. ${point}`).join('\n\n')}1920Read the full post: ${blogPost.url}2122What's your take? 👇`,2324 // LinkedIn professional post25 linkedIn: `📝 ${blogPost.title}2627${blogPost.summary}2829Key insights:3031${blogPost.keyPoints.map(point => `✅ ${point}`).join('\n')}3233${blogPost.hashtags.map(h => `#${h}`).join(' ')}3435Full article in comments ��`,3637 // Instagram caption (visual focus)38 instagram: `${blogPost.title} 📌3940${blogPost.summary}4142Swipe through for the key insights! ��4344.45.46.4748${blogPost.hashtags.slice(0, 30).map(h => `#${h}`).join(' ')}`,4950 // Email newsletter snippet51 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`,5960 // Quote graphics text61 quoteGraphics: blogPost.quotableLines.map(quote => ({62 text: `"${quote}"`,63 attribution: blogPost.author,64 style: 'quote_card'65 }))66};6768return { repurposed };Checkpoint
Content repurposer tạo bao nhiêu versions từ một blog post?
🔧 Platform Integration Tips
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?
📋 Best Practices
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?
📝 Bài Tập Thực Hành
Build your social automation:
- Set up cross-platform posting workflow
- Implement content scheduling queue
- Add engagement auto-responder
- Create social listening alerts
- Build content repurposing pipeline
Amplify your reach! 📱
Checkpoint
Bạn đã hoàn thành những challenges nào trong bài tập?
🧠 Key Takeaways
- 🎯 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.
