iT邦幫忙

2025 iThome 鐵人賽

DAY 10
0
DevOps

Mac 環境 n8n 30 天學習計畫系列 第 10

Day10:n8n + Notion 新增資料庫項目

  • 分享至 

  • xImage
  •  

Step 1. 建立 Notion Integration

  1. Notion My Integrations → 點 + New integration
  2. 填名稱(例如 n8n-test)、選你的 workspace。
  3. 權限勾選 Read content / Insert content / Update content(或直接選 Write)。
  4. 建立後會得到一組 Integration Token(長得像 ntn_xxx...),先複製好。
    https://ithelp.ithome.com.tw/upload/images/20250923/20169144H2r4POEYZ0.png

Step 2. 分享 Database 給 Integration

  1. 打開你要寫入的 Notion 資料庫頁面(表格檢視)。
  2. 點右上角 Share → 在 Invite 欄輸入剛建立的 Integration 名稱(例如 n8n-test)。
  3. 設定為 Editor 權限,按 Invite。
    👉 沒做這步,API 一定會報 403 Forbidden
    https://ithelp.ithome.com.tw/upload/images/20250923/20169144fcCndr98M9.png

Step 3. 在 n8n 建立 Notion Credential

  1. 在 n8n 左邊 → Credentials+ Add Credential
  2. 搜尋 Notion → 點選。
  3. Integration Token 欄貼上剛剛複製的 ntn_xxx...
  4. Save 儲存。
    https://ithelp.ithome.com.tw/upload/images/20250923/20169144fwEEoFCnEJ.png

Step 4. 建 Workflow(3 個節點)

https://ithelp.ithome.com.tw/upload/images/20250923/20169144acM1cyFWv4.png

  1. 新增 Manual Trigger node:

    • 這個 Node 的作用是:手動按「執行」時才會觸發流程。
  2. 新增 Function node:

    • Purpose:產生一筆要新增的資料。
    • Code 填入(範例):
    return [{
      json: {
        title: "自動任務 " + new Date().toLocaleString(),
        status: "Todo",
        tags: ["n8n","Day10"],
        due: new Date(Date.now() + 86400000).toISOString(), // 明天
        priority: 1,
        done: false,
        notes: "由 n8n 自動新增"
      }
    }];
    

https://ithelp.ithome.com.tw/upload/images/20250923/20169144cB77vUiSbV.png
3. 新增 Notion node:

  • Resource 選 Page

  • Operation 選 Create

  • Credential 選剛建好的 Notion

  • Database ID 貼上你 Notion database 的 id(網址中間那串 UUID)

  • Properties Mapping:

    • Name (Title) → ={{$json["title"]}}
    • Status (Select) → ={{$json["status"]}}
    • Tags (Multi-select) → ={{$json["tags"]}}
    • Due (Date) → ={{$json["due"]}}
    • Priority (Number) → ={{$json["priority"]}}
    • Done (Checkbox) → ={{$json["done"]}}
    • Notes (Rich text) → ={{$json["notes"]}}

https://ithelp.ithome.com.tw/upload/images/20250923/20169144fA9HHwjfDA.png

https://ithelp.ithome.com.tw/upload/images/20250923/20169144pEFVk1okPg.png

Step 5. 測試執行

  1. 點選 Notion node → Execute Node。
  2. 到 Notion database → 應該會出現一筆新資料。
    https://ithelp.ithome.com.tw/upload/images/20250923/20169144ZJkPOBed1z.png

https://ithelp.ithome.com.tw/upload/images/20250923/20169144TGVP5QPE75.png


上一篇
Day 9:Google Sheets 寫入新增資料
下一篇
📝Day11:Notion CRUD 自動化練習
系列文
Mac 環境 n8n 30 天學習計畫12
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言