Templates / Build custom AI agent with LangChain & Gemini (self-hosted)

Build custom AI agent with LangChain & Gemini (self-hosted)

Needs changes

by shepard · 6,183 views · created 2025-03-26 · Miscellaneous, AI Chatbot

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: LangChain Code (legacy). 1 breaking item(s) found. Static check, last run 2026-10-19.

What to replace before upgrading

Removed in 3.0Replace with
LangChain Code (legacy)
Construct & Execute LLM Prompt
No direct replacement

Nodes used (4)

Google Gemini Chat ModelSimple MemoryLangChain Code

What it does

Overview This workflow leverages the LangChain code node to implement a fully customizable conversational agent. Ideal for users who need granular control over their agent's prompts while reducing unnecessary token consumption from reserved tool-calling functionality (compared to n8n's built-in Conversation Agent). !截屏20250327 17.53.50.png(fileId:1063) Setup Instructions 1. Configure Gemini Credentials: Set up your Google Gemini API key (Get API key here if needed). Alternatively, you may use other AI provider nodes. 2. Interaction Methods: - Test directly in the workflow editor using the "Chat" button - Activate the workflow and access the chat interface via the URL provided by the When Chat Message Received node Customization Options 1. Interface Settings: Configure chat UI elements (e.g., title) in the When Chat Message Received node 2. Prompt Engineering: - Define agent personality and conversation structure in the Construct & Execute LLM Prompt node's template variable - ⚠️ Template must preserve {chathistory} and {input} placeholders for proper LangChain operation 3. Model Selection: Swap language models through the language model input field in Construct & Execute LLM Prompt 4. Memory Control: Adjust conversation history length in the Store Conversation History node Requirements: ⚠️ This workflow uses the LangChain Code node, which only works on self-hosted n8n. (Refer to LangChain Code node docs)

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.