iT邦幫忙

2025 iThome 鐵人賽

DAY 19
0
生成式 AI

從零開始 : 學習運用 n8n 與 Dify 的 AI 自動化實戰系列 第 19

Day 19 : 將資料儲存至Google sheet

  • 分享至 

  • xImage
  •  

今日目標:

將 AI 清理後的 JSON 數據,精確寫入 Google Sheets 的對應欄位。

一、Google Sheets 前置作業

要讓 n8n 成功寫入,Google Sheets 必須先設定好權限和欄位。

1. 建立 Google Sheets 文件

  • 操作: 建立一個新的 Google Sheets,命名為:「AI 結構化會議記錄」。
  • 取得 Spreadsheet ID: 複製瀏覽器網址列中 /d//edit 之間的長串 ID。

2. 設定工作表 Header(欄位名稱)- 關鍵步驟

為了讓 n8n 的節點功能運作,工作表的第一列(Header)必須與 AI 輸出的 JSON Key 名稱完全一致。

  • 操作: 在工作表的第一列(A1, B1, C1, D1...)輸入以下英文名稱:
A1 B1 C1 D1
meeting_title type summary action_items

https://ithelp.ithome.com.tw/upload/images/20251017/20169078gbZo19fF11.png

3. 授予 n8n 寫入權限 - 權限設定

  • 操作:
    • 在 Google Sheets 文件中,點擊右上角的 分享 按鈕。
    • 輸入 n8n Google Credentials 憑證所對應的 Google 帳號 Gmail,並授予 編輯者 權限。
    • 請確保 n8n 已經通過 Google 的 OAuth 驗證,能成功連接到自己的 Google 帳號。

二、n8n 流程建構:替換與設定 Google Sheets 節點

流程是:Manual Trigger -> HTTP Request ->Function (Code) -> Google Sheets

1. 移除 Notion 節點 (沿用前一天的節點設置)

  • 停用或刪除之前用來寫入 Notion 的節點。

2. 新增 Google Sheets 節點

  • 點擊 Function 節點後面的 +,搜尋並新增 Google Sheets 節點。

3. Google Sheets 節點設定(Parameters 區塊)

設定項目 值或操作 說明
Credential 選擇 Google Sheets 憑證 確保憑證有足夠的 Sheets 權限。
Resource 選擇 Sheet Within Document 我們要操作的是整個試算表。
Operation 選擇 Append Row 在工作表的末尾新增一行資料。
Document 貼上步驟一中取得的 Spreadsheet ID或使用By URL貼上連結網址。 準確指向目標檔案。
Sheet Name 輸入 sheet1 (或其他使用的工作表名稱)。 準確指向目標工作表。

https://ithelp.ithome.com.tw/upload/images/20251017/201690786FesFK2TDA.png

4. Google Sheets 節點設定(Values 區塊)

這是將 AI 數據寫入到正確欄位的關鍵步驟。

  • Values to SendMapping Column Mode: 選擇 Map Each Column Manually
Column Header Value (Expression) 引用來源
meeting_title {{ $json.meeting_title }} 引用 Function 節點輸出
type {{ $json.type }} 引用 Function 節點輸出
summary {{ $json.summary }} 引用 Function 節點輸出
action_items {{ $json.action_items }} 引用 Function 節點輸出

https://ithelp.ithome.com.tw/upload/images/20251017/20169078OPWhGqNPDK.png

三、最終驗證:展示通用性和成果

執行整個 n8n 流程後,Google Sheets 中會新增一行資料,完美地填入 AI 結構化後的資訊。

如圖:
https://ithelp.ithome.com.tw/upload/images/20251017/20169078l5FXXmgmeN.png

Execute Output (含節點圖):
https://ithelp.ithome.com.tw/upload/images/20251017/20169078mWdPUzqpLr.png


上一篇
Day 18 : Notion - AI 會議記錄自動結構化
下一篇
Day 20 : n8n 串接 Dify RAG - 會議摘要的自動歸檔
系列文
從零開始 : 學習運用 n8n 與 Dify 的 AI 自動化實戰30
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言