Open2

n8n , AI エージェント 設定

knaka Tech-Blogknaka Tech-Blog

概要

  • n8n , AI Agent ノード設定メモになります。
  • ダウンロード版 ローカル環境

[ 公開 2025/08/06 ]


環境

  • n8n Version1.102.4
  • docker

関連



  • ノード種類 、右側の + ボタン、ノード検索する
  • Chat Trigger
  • AI Agent
  • Google Gemini Chat Model

  • AI Agent
  • Prompt: 変更なし , {{ $json.chatInput }}



  • Google Gemini Chat Model
  • Credential to cnonnect with: Google Gemini(PaKM) Api acount
  • 右の鉛筆: API KEY入力あり、 メモした Gemini key入力


  • chat 確認, 左下に chat枠表示される。
  • 下テキスト欄に、プロンプト入力、実行
  • AI chatできる。

knaka Tech-Blogknaka Tech-Blog

Webhook から、AI エージェント 実行

  • 前回の、discordと似ていますが。webhook使い API操作する

環境

  • n8n Version1.102.4
  • docker

  • curl の実行参考
curl -X POST -H "Content-Type: application/json" \
 -d '{"text": "hello"}' \
 http://localhost:5678/webhook/40a618df-bce2-4083-8ad1-60703cccc87b

  • ノード種類
  • Webhook
  • AI Agent
  • Google Gemini Chat Model
  • Structured Output Parser (LLM からのデータ出力)


  • Webhook
  • Production URL: メモしておく
  • HTTP Method: POST
  • Respond: When Last Node Finishes
  • Response Data: fisrt entity JSON

  • AI Agent
  • Prompt: {{ $json.body.text }}
  • Require Specific output format: ON

  • Google Gemini Chat Model , 前回と同じ
  • Credential to cnonnect with: Google Gemini(PaKM) Api acount
  • 右の鉛筆: API KEY入力あり、 メモした Gemini key入力

  • Structured Output Parser
  • 上記の AI Agent画面、output parser リンク
    (Require specific output format の下)
  • parser 種類が表示される、
  • Structured Output Parser 選択
  • JSON Example: jsonレスポンス設定
{
	"result": "出力内容"
}


  • curlテスト
  • POST通信できました
$ curl -X POST -H "Content-Type: application/json" \
 -d '{"text": "日本の、鎌倉時代わかります? 100文字以内で回答して欲しい。"}' \
 http://localhost:5678/webhook/40a618df-bce2-4083-8ad1-60703cccc87b

{"output":{"result":"鎌倉時代は、源頼朝が鎌倉幕府を開いた1185年から1333年までの武士による政治の時代です。武士 の力が強まり、封建社会が確立しました。"}}