สร้าง Content Calendar อัตโนมัติด้วย n8n + Google Sheets
คู่มือสร้างระบบ Content Calendar อัตโนมัติด้วย n8n และ Google Sheets วางแผนโพสต์ล่วงหน้า กำหนดเวลา แจกจ่ายไปหลาย platform พร้อมติดตามสถานะ
ทีม content ส่วนใหญ่ใช้ Notion, Google Sheets หรือ Trello วางแผนคอนเทนต์อยู่แล้ว ปัญหาคือต้องเอาข้อมูลในนั้นไปโพสต์เองทีละแพลตฟอร์มอีกรอบ n8n ช่วยขั้นตอนสุดท้ายนี้ได้ เชื่อม Google Sheets เป็น content calendar แล้วให้ workflow รันเองตามเวลาที่กำหนด ทีมทำงานวางแผนต่อไปได้เลยโดยไม่ต้องยุ่งกับขั้นตอนการโพสต์อีก
ออกแบบ Google Sheets ให้ทำงานกับ n8n ได้ดี
โครงสร้าง sheet ที่ดีคือหัวใจของระบบนี้ ถ้าออกแบบไม่ดีตั้งแต่ต้น workflow จะซับซ้อนโดยไม่จำเป็น
Sheet: content_calendar (sheet หลัก)
| คอลัมน์ | Type | ตัวอย่าง |
|---|---|---|
| id | Text | POST_001 |
| scheduled_datetime | DateTime | 2026-04-15 10:00:00 |
| platform | Text | facebook,instagram,line |
| content_type | Text | image, video, text, carousel |
| caption | Text | ข้อความโพสต์ |
| hashtags | Text | #n8n #automation |
| media_url | Text | https://drive.google.com/… |
| link_url | Text | https://yoursite.com/blog/… |
| status | Text | pending |
| posted_at | DateTime | (ว่างไว้ ให้ n8n กรอก) |
| post_ids | Text | (ว่างไว้ ให้ n8n กรอก) |
| notes | Text | หมายเหตุสำหรับทีม |
Sheet: platform_config (เก็บค่าตั้งต้น)
| platform | page_id | active |
|---|---|---|
| 12345678 | TRUE | |
| ig_user_id_here | TRUE | |
| line | @lineoaid | TRUE |
Sheet: post_log (log ทุก request)
เก็บ timestamp, post_id, platform, status, error_message ทุกครั้งที่รัน workflow ช่วยให้ debug ได้ง่ายเมื่อเกิดปัญหา
โครงสร้าง Workflow หลัก
Schedule Trigger (ทุก 15 นาที)
→ Google Sheets: ดึง pending posts ที่ถึงเวลา
→ IF: มีโพสต์ที่รอ?
→ YES: Split In Batches (แยกทีละโพสต์)
→ Code: Parse platform list
→ Loop: วน platform
→ Switch: แยก handler ตาม platform
├── Facebook Handler
├── Instagram Handler
├── LINE Handler
└── Others Handler
→ Merge: รวม results
→ Google Sheets: อัปเดต status + post_ids
→ Google Sheets: เขียน post_log
→ NO: End
ขั้นตอนที่ 1: ดึงโพสต์ที่ถึงเวลา
Google Sheets node ตั้งค่าให้ filter ข้อมูล แต่เพื่อความยืดหยุ่น แนะนำดึงมาก่อนแล้วกรองด้วย Code node
// Code node: กรองโพสต์ที่พร้อมโพสต์
const now = new Date();
const pendingPosts = $input.all().filter(item => {
const scheduledTime = new Date(item.json.scheduled_datetime);
return item.json.status === 'pending' && scheduledTime <= now;
});
return pendingPosts;
ขั้นตอนที่ 2: แยก Platform
หนึ่งโพสต์อาจต้องการโพสต์หลาย platform พร้อมกัน Code node แยก string เป็น array ก่อน
// Code node: Parse platforms
const post = $input.first().json;
const platforms = post.platform.split(',').map(p => p.trim());
return platforms.map(platform => ({
json: {
...post,
target_platform: platform
}
}));
ขั้นตอนที่ 3: Handler แต่ละ Platform
Facebook Handler:
HTTP Request node
Method: POST
URL: https://graph.facebook.com/v18.0/{page_id}/feed
Auth: Header Auth (Bearer token)
Body:
{
"message": "{{ $json.caption }} {{ $json.hashtags }}",
"link": "{{ $json.link_url }}"
}
LINE Handler:
HTTP Request node
Method: POST
URL: https://api.line.me/v2/bot/message/broadcast
Headers:
Authorization: Bearer {channel_access_token}
Body:
{
"messages": [{
"type": "text",
"text": "{{ $json.caption }}"
}]
}
ขั้นตอนที่ 4: อัปเดตสถานะ
เมื่อโพสต์สำเร็จทุก platform แล้ว อัปเดต Google Sheets
ใช้ Code node สร้าง update object ก่อน
const results = $input.all();
const postIds = results.map(r =>
`${r.json.target_platform}:${r.json.post_id || 'ok'}`
).join(', ');
return [{
json: {
row_number: results[0].json.row_number,
status: 'posted',
posted_at: new Date().toISOString(),
post_ids: postIds
}
}];
จากนั้น Google Sheets node Update Row ตาม row_number
จัดการ Error อย่างถูกต้อง
เพิ่ม Error handling ใน workflow เพื่อไม่ให้โพสต์ติด pending ตลอดกาล
เปิด “Continue on fail” ใน HTTP Request nodes ทั้งหมด แล้วเพิ่ม IF node ตรวจสอบ response code
// Code node: ตรวจสอบ result และตั้ง status
const results = $input.all();
const hasError = results.some(r => r.json.error !== undefined);
return [{
json: {
final_status: hasError ? 'error' : 'posted',
error_detail: hasError ? JSON.stringify(
results.filter(r => r.json.error).map(r => ({
platform: r.json.target_platform,
error: r.json.error
}))
) : null
}
}];
โพสต์ที่ error จะ status เป็น “error” ไม่ใช่ “posted” ทีมเห็นใน sheet แล้วแก้ไขและเปลี่ยน status กลับเป็น “pending” เพื่อให้ retry
ฟีเจอร์เพิ่มเติมที่ทำให้ระบบดีขึ้น
Best Time Suggester — เพิ่ม workflow แยกที่รันสัปดาห์ละครั้ง ดึง engagement data จากทุก platform วิเคราะห์ว่าช่วงเวลาไหน engagement สูงที่สุด แล้วเขียนแนะนำลงใน sheet แยก ทีมเอาไปใช้ประกอบการตัดสินใจเวลาโพสต์
Image Resize — บาง platform ต้องการ aspect ratio ต่างกัน เพิ่ม Cloudinary API node เพื่อ resize รูปก่อนส่ง ไม่ต้องเตรียมรูปหลาย version เอง
Weekly Summary Report — Schedule Trigger รันทุกวันจันทร์ ดึงข้อมูลจาก post_log และ platform insights ของสัปดาห์ที่แล้ว สรุปเป็น email หรือ LINE message ให้ทีม
Content Approval Flow — เพิ่มคอลัมน์ “approved_by” ใน sheet workflow ตรวจว่า approved ก่อน publish ทีมใหม่หรือคอนเทนต์ sensitive ต้องผ่านคน approve ก่อน
ข้อดีของการใช้ Google Sheets เป็น CMS
- ทีมทุกคนที่ใช้ Google Workspace ได้เลยทันที ไม่ต้องเรียนระบบใหม่
- สามารถ import/export ข้อมูล CSV ได้ง่าย
- Google Sheets Add-on และ Formula ช่วย filter และวิเคราะห์ข้อมูลใน sheet ได้เอง
- Real-time collaboration หลายคนทำงานพร้อมกันได้
- Version history เห็นว่าใครแก้ไขอะไรเมื่อไหร่
อยากเรียน n8n แบบเป็นระบบ ตั้งแต่เริ่มต้นจนสร้าง Workflow ใช้งานจริงได้ ลองดู คอร์สสอน n8n ที่ aiunlock.co
Related posts
สร้างคอนเทนต์อัตโนมัติด้วย AI + n8n
สร้างระบบผลิตคอนเทนต์ Social Media อัตโนมัติด้วย AI และ n8n ตั้งแต่เขียนข้อความ ไปจนถึงโพสต์ Facebook, Instagram, Line
สร้าง Dashboard อัตโนมัติบน Google Sheets ด้วย n8n
ใช้ n8n ดึงข้อมูลจากหลายแหล่ง รวบรวม และอัปเดต Google Sheets Dashboard อัตโนมัติทุกวัน ไม่ต้องคีย์ข้อมูลเอง
รวบรวม Social Media Analytics อัตโนมัติด้วย n8n
สร้าง workflow n8n ดึง analytics จาก Facebook Instagram TikTok มารวมใน Google Sheets เพื่อวิเคราะห์ performance ข้ามแพลตฟอร์มในที่เดียว