n8n Thai
by n8n Thai

n8n x Notion: ซิงค์และจัดการ Notion อัตโนมัติ

วิธีเชื่อมต่อ n8n กับ Notion เพื่ออ่าน สร้าง และอัปเดต Page และ Database อัตโนมัติ พร้อม Workflow จริงสำหรับทีม

n8n x Notion: ซิงค์และจัดการ Notion อัตโนมัติ

Notion กลายเป็นศูนย์กลางการทำงานของทีมจำนวนมาก ทั้งเก็บเอกสาร, จัดการโปรเจค, ติดตาม Task และเก็บฐานความรู้ขององค์กร ปัญหาที่หลายทีมเจอคือข้อมูลใน Notion ยังต้องอัปเดตด้วยมือจากระบบอื่น เช่น ต้องมาสร้าง Task ใน Notion หลังจากรับออร์เดอร์ใหม่ หรือต้องมา Update สถานะหลังจาก Email ตอบกลับ

n8n แก้ปัญหานี้โดยตรงด้วย Notion Node ที่รองรับทั้งการอ่านและเขียนข้อมูลใน Notion Database และ Page ทำให้ Notion กลายเป็นส่วนหนึ่งของ Automation ที่ทำงานเองได้

ตั้งค่า Notion Integration

Notion ใช้ระบบ Integration (Bot) ในการให้สิทธิ์ภายนอกเข้าถึงข้อมูล

ขั้นตอนที่ 1: สร้าง Notion Integration

  1. ไปที่ notion.so/my-integrations
  2. กด New Integration
  3. ตั้งชื่อ เช่น n8n Automation
  4. เลือก Workspace
  5. ตั้ง Capabilities ที่ต้องการ เช่น Read Content, Insert Content, Update Content
  6. กด Submit แล้ว Copy Internal Integration Token

ขั้นตอนที่ 2: เพิ่ม Integration เข้า Database/Page Integration ไม่มีสิทธิ์เข้าถึง Notion โดย Default ต้อง Share แต่ละ Database/Page ให้ Integration ก่อน:

  1. เปิด Database หรือ Page ที่ต้องการ
  2. กด (สามจุด) มุมบนขวา
  3. เลือก Add connections
  4. ค้นหาและเลือก Integration ที่สร้างไว้

ขั้นตอนที่ 3: ตั้งค่าใน n8n

  1. ไปที่ Settings > Credentials > Add Credential
  2. เลือก Notion API
  3. วาง Internal Integration Token แล้ว Save

หา Database ID

Database ID ใน Notion หาได้จาก URL:

https://www.notion.so/myworkspace/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?v=...
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                           Database ID (32 ตัว)

หรือหาจากการ Share Link ของ Database

Operation: Query Database — ดึงข้อมูลจาก Database

ตัวอย่าง: ดึง Task ที่ยังไม่เสร็จ

  1. เพิ่ม Notion Node
  2. เลือก Resource: Database Page
  3. เลือก Operation: Get Many
  4. ใส่ Database ID
  5. เพิ่ม Filter:
    • Property: Status
    • Type: select
    • Condition: equals
    • Value: In Progress

รองรับ Filter หลายเงื่อนไขทั้งแบบ AND และ OR รองรับ Sort ตาม Property และรองรับ Pagination อัตโนมัติ

Operation: Create Page — สร้าง Page ใหม่ใน Database

ตัวอย่าง: สร้าง Task ใหม่ใน Notion เมื่อรับออร์เดอร์

  1. เลือก Operation: Create
  2. ระบุ Database ID
  3. กำหนด Properties:
Title: "จัดการออร์เดอร์ #{{ $json.order_id }}"
Status: "Not Started"
Priority: "High"
Due Date: {{ $now.plus(2, 'days').format('YYYY-MM-DD') }}
Customer: "{{ $json.customer_name }}"
Amount: {{ $json.total_amount }}

Properties ใน Notion มีหลาย Type ต้องใส่ให้ถูก Format:

  • Title{ "title": [{ "text": { "content": "ชื่อ" } }] }
  • Select{ "select": { "name": "ค่า" } }
  • Date{ "date": { "start": "2026-04-10" } }
  • Number{ "number": 1500 }
  • Checkbox{ "checkbox": true }

n8n Notion Node จัดการ Format เหล่านี้ให้อัตโนมัติ ไม่ต้องเขียน JSON เอง

Operation: Update Page — อัปเดต Page ที่มีอยู่

ตัวอย่าง: อัปเดตสถานะ Task เมื่อได้รับการชำระเงิน

  1. เลือก Operation: Update
  2. ใส่ Page ID ของ Task ที่ต้องการ Update
  3. เปลี่ยน Property:
    • StatusDone
    • Completed Date{{ $now.format('YYYY-MM-DD') }}

Operation: Get Page — ดึงข้อมูล Page เดียว

ใช้เมื่อรู้ Page ID แล้วและต้องการอ่านข้อมูลทั้งหมดของ Page นั้น เช่น ดึงรายละเอียดของ Task ก่อนส่งแจ้งเตือน

Workflow ตัวอย่างที่ 1: Sync Form ลง Notion

โจทย์: รับ Contact Form จากเว็บไซต์แล้วสร้าง CRM Record ใน Notion

Workflow:

  1. Webhook Trigger — รับข้อมูล Contact Form
  2. Notion Create — สร้าง Page ใน Database “Contacts”
    • Name: {{ $json.name }}
    • Email: {{ $json.email }}
    • Message: {{ $json.message }}
    • Source: Website
    • Status: New Lead
  3. LINE Notify / Slack — แจ้งทีม Sales ว่ามี Lead ใหม่

Workflow ตัวอย่างที่ 2: Daily Standup Report

โจทย์: ดึง Task ที่ทำเสร็จเมื่อวานจาก Notion แล้วสรุปส่งทีมทุกเช้า

Workflow:

  1. Schedule Trigger — ทุกวัน 8:30 น.
  2. Notion Query — ดึง Page ที่:
    • Status = Done
    • Completed Date = Yesterday
  3. Code Node — Format รายการเป็นข้อความ
    const items = $input.all();
    const tasks = items.map(i => `• ${i.json.properties.Name.title[0].plain_text}`);
    return [{ json: { summary: tasks.join('\n') } }];
  4. LINE Notify — ส่งสรุปไปยัง LINE Group

Workflow ตัวอย่างที่ 3: ซิงค์ Notion กับ Google Calendar

โจทย์: เมื่อสร้าง Event ใน Notion Database ให้สร้าง Google Calendar Event อัตโนมัติ

Workflow:

  1. Schedule Trigger — ทุก 15 นาที
  2. Notion Query — ดึง Event ที่ Synced = false
  3. Google Calendar Create — สร้าง Event ตามข้อมูลจาก Notion
  4. Notion Update — อัปเดต Synced = true และบันทึก Calendar Event ID
  5. IF Node (Error Branch) — ถ้า Google Calendar ล้มเหลว Log Error ลง Notion Page

เคล็ดลับการทำงานกับ Notion Node

ปัญหา: Properties ซับซ้อน ไม่รู้จะ Map ยังไง ให้ใช้ Notion Get ดึง Page ที่มีอยู่แล้วดู JSON Structure ของ Properties ก่อน จะเห็นรูปแบบที่ต้องใช้

ปัญหา: Rate Limit Notion API อนุญาต 3 Requests ต่อวินาที ถ้า Workflow Loop หลาย Page ให้เพิ่ม Wait Node (300ms) ระหว่าง Request

ปัญหา: Rich Text ที่มีหลาย Block ข้อความใน Notion เก็บเป็น Array ของ Text Block ถ้าต้องการดึงข้อความธรรมดาออกมาให้ใช้ .plain_text Property แทน

// ดึง plain text จาก title
const title = item.json.properties.Name.title
  .map(t => t.plain_text)
  .join('');

ปัญหา: ไม่เห็น Database ใน n8n ตรวจสอบว่า Integration มีสิทธิ์เข้าถึง Database นั้นหรือยัง ต้อง Share Database ให้ Integration ก่อนเสมอ

อยากเรียน n8n แบบเป็นระบบ ตั้งแต่เริ่มต้นจนสร้าง Workflow ใช้งานจริงได้ ลองดู คอร์สสอน n8n ที่ aiunlock.co

Related posts