{
  "name": "Build custom AI agent with LangChain & Gemini (self-hosted)",
  "nodes": [
    {
      "id": "8bd5382d-f302-4e58-b377-7fc5a22ef994",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -220,
        0
      ]
    },
    {
      "id": "6ae8a247-4077-4569-9e2c-bb68bcecd044",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        80,
        240
      ]
    },
    {
      "id": "bbe6dcfa-430f-43f9-b0e9-3cf751b98818",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -240
      ],
      "parameters": {
        "width": 260,
        "height": 220,
        "content": "👇 **Prompt Engineering**\n   - Define agent personality and conversation structure in the `Construct & Execute LLM Prompt` node's template variable  \n   - ⚠️ Template must preserve `{chat_history}` and"
      }
    },
    {
      "id": "892a431a-6ddf-47fc-8517-1928ee99c95b",
      "name": "Store conversation history",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        280,
        240
      ]
    },
    {
      "id": "f9a22dbf-cac7-4d70-85b3-50c44a2015d5",
      "name": "Construct & Execute LLM Prompt",
      "type": "@n8n/n8n-nodes-langchain.code",
      "position": [
        380,
        0
      ]
    },
    {
      "id": "fe104d19-a24d-48b3-a0ac-7d3923145373",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -260
      ],
      "parameters": {
        "width": 420,
        "height": 240,
        "content": "### Setup Instructions  \n1. **Configure Gemini Credentials**: Set up your Google Gemini API key ([Get API key here](https://ai.google.dev/) if needed). Alternatively, you may use other AI provider nod"
      }
    },
    {
      "id": "f166214d-52b7-4118-9b54-0b723a06471a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        160
      ],
      "parameters": {
        "width": null,
        "height": 100,
        "content": "👆 **Interface Settings**\nConfigure chat UI elements (e.g., title) in the `When Chat Message Received` node  "
      }
    },
    {
      "id": "da6ca0d6-d2a1-47ff-9ff3-9785d61db9f3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        420
      ],
      "parameters": {
        "width": 200,
        "height": 140,
        "content": "👆 **Model Selection**\nSwap language models through the `language model` input field in `Construct & Execute LLM Prompt`  "
      }
    },
    {
      "id": "0b4dd1ac-8767-4590-8c25-36cba73e46b6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        420
      ],
      "parameters": {
        "width": 200,
        "height": 140,
        "content": "👆 **Memory Control**\nAdjust conversation history length in the `Store Conversation History` node  "
      }
    }
  ],
  "connections": {
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Construct & Execute LLM Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Store conversation history": {
      "ai_memory": [
        [
          {
            "node": "Construct & Execute LLM Prompt",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "When chat message received",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Construct & Execute LLM Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Construct & Execute LLM Prompt": {
      "main": [
        []
      ],
      "ai_memory": [
        []
      ]
    }
  }
}