---
title: n8n 使用 Google Gemini 建立對話結果步驟指南
updated: 2025-06-03 02:03:21Z
created: 2025-06-02 09:44:25Z
latitude: 25.03296940
longitude: 121.56541770
altitude: 0.0000
---

### n8n 使用 Google Gemini 建立對話結果步驟指南

本指南將帶您了解如何在 n8n 工作流程中整合 Google Gemini，以建立基於 AI 的對話結果。

**步驟 1：建立 AI Agent 節點**

首先，您需要在 n8n 工作流程中新增一個 AI Agent 節點。

- 在 n8n 編輯器中，點擊左側的「+」按鈕或在空白處右鍵，然後選擇「Add Node」。
    
- 在搜尋框中輸入「AI Agent」。
    
- 選擇位於「AI > AI Agent」下的「AI Agent」節點。
    

![顯示 n8n 編輯器中，使用者在搜尋框中輸入「AI Agent」後，選擇「AI > AI Agent」的畫面。](../_resources/959a413a39ba3d47dbc58f83ba1ef371.png)

&nbsp;

**步驟 2：寫入 Prompt**

AI Agent 節點建立後，您需要為其設定一個 Prompt。這是您希望 Gemini 模型遵循的指令或情境。

- 雙擊「AI Agent」節點以開啟其設定面板。
    
    &nbsp;
    
- 在「Source for Prompt (User Message)」下拉選單中，選擇「Define below」。
    
    &nbsp;
    
- 在「Prompt (User Message)」欄位中，輸入您希望 AI Agent 執行的任務或對話內容。例如，您可以寫入：「請提醒我要喝水」。
    

![ 顯示 AI Agent 節點的設定面板，其中「Prompt」欄位已經填寫了示範性的 Prompt 內容。](../_resources/1842e8f78c5242a47746c51de658b8d6.png)

![f11686d6f27d14d4337e91370d93ce11.png](../_resources/f11686d6f27d14d4337e91370d93ce11.png)

**步驟 3：選擇模型 (Google Gemini)**

接下來，您需要指定 AI Agent 將使用的模型。

- 在 AI Agent 節點的設定面板中，找到「Model」選項。
    
- 點擊下拉選單，然後選擇「Google Gemini」。
    

![顯示 AI Agent 節點的設定面板，其中「Model」下拉選單被點開，並選中了「Google Gemini」](../_resources/89a2dd1f18b6bab1ba33b57f78778ced.png)

&nbsp;

**步驟 4：取得 Google Gemini API Key**

在使用 Google Gemini 之前，您需要一個 API Key 來進行身份驗證。

- 開啟您的網頁瀏覽器，並在搜尋引擎中輸入「Google Gemini API」。
    
- 點擊搜尋結果中指向 「[Get a Gemini API key](https://ai.google.dev/gemini-api/docs/api-key "null")」 網站的連結，通常會是 `https://ai.google.dev` 開頭的網址。
    
- 在該網站上，尋找「Get a Gemini API key」或類似的選項來獲取您的 API Key。
    
- 建立一個新的 API Key。請確保妥善保管此 Key，切勿公開。
    

![搜尋 Google AI Studio 或 Google Cloud Console 取得 API Key](../_resources/81c9bc2ecf717ab234a5764e94853740.png)  
![顯示 Google 搜尋結果頁面，或 Google AI Studio/Google Cloud Console 中取得 API Key 的介面。](../_resources/8afb42083052a045007ed35020914022.png)

**步驟 5：填入 Gemini API Key**

將您在步驟 4 中取得的 Gemini API Key 填入 n8n 的設定中。

- 回到 n8n 的 AI Agent 節點設定面板。
    
- 在「Credential to connect with」下拉選單中，選擇「+ Create new credential」。
    
- 這將會開啟一個新的視窗或彈出框，標題可能為「Google Gemini (PaLM) Api account」。
    
- 在此視窗中，找到「API Key」欄位。
    
- 將您複製的 API Key 貼入此欄位。
    
- 點擊「Save」按鈕儲存憑證。
    

![顯示 Google Gemini Chat Model 節點的憑證設定，先點擊「+ Create new credential」](../_resources/fa7c3014d54759616b59a439d9d9cbb2.png)  
![然後在新開啟的「Google Gemini (PaLM) Api account」視窗中，將 API Key 貼入「API Key」欄位並儲存。](../_resources/beeb54ea85c6b8b00f3b6e5d97741a1b.png)

**步驟 6：選擇模型 2.5 Flash**

Google Gemini 提供多種模型，您可以根據您的需求選擇。目前，我們選擇 2.5 Flash 模型。

- 在 AI Agent 節點的設定面板中，找到「Model」選項。
    
- 點擊下拉選單，然後選擇「models/gemini-2.5-flash-preview-05-20」（或您希望使用的其他版本，例如 `models/gemini-2.5-flash-preview-04-17` 等）。
    

![顯示 AI Agent 節點的設定面板，其中「Google Gemini Model」下拉選單被點開，並選中了「2.5 Flash」。](../_resources/42bc55be10a35677a794c86a6dad9126.png)

**步驟 7：測試工作流程**

現在，您已經完成了所有必要的配置，可以測試您的工作流程了。

- 點擊 n8n 工作流程右上角的「Test Workflow」或「Execute Workflow」按鈕。
    
- 如果一切配置正確，您將在輸出中看到 Google Gemini 生成的對話結果。
    

![顯示 n8n 工作流程執行後的結果，其中包含 Google Gemini 的輸出。](../_resources/609acd59ecb28c6e7e77f147dfbeb329.png)