Custom AI Agent with LangChain & Gemini (Self-Hosted)

Build a customizable conversational AI agent using LangChain Code node and Gemini API in self-hosted n8n. Offers granular prompt control, reduced token usage, and chat interface for efficient interactions.

n8n
Custom AI Agent with LangChain & Gemini (Self-Hosted)

This workflow implements a fully customizable conversational AI agent leveraging the LangChain Code node integrated with Google Gemini API, designed exclusively for self-hosted n8n instances. It provides granular control over agent prompts, personality, and conversation structure, avoiding unnecessary token consumption from built-in tool-calling features in n8n's standard agents. Users can test directly in the editor or activate a web-based chat interface via the 'When Chat Message Received' trigger node.

Key benefits include flexible model swapping (e.g., other LLMs), adjustable conversation history length for memory management, and customizable UI elements like chat titles. The prompt template must retain {chat_history} and {input} placeholders for seamless LangChain operation, enabling advanced prompt engineering tailored to specific use cases such as customer support bots, personal assistants, or interactive Q&A systems.

Ideal for developers and businesses needing cost-effective, high-control AI chat solutions. Setup requires Gemini API credentials and self-hosted n8n; customization options span interface, prompts, models, and memory, making it versatile for personal projects or scalable applications while minimizing API costs through optimized token usage.

$22.99
Last updated August 29, 2026
30-day money-back guarantee
Instant download
Lifetime updates included

New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.

Secure checkout powered by Stripe

Support

How to import this workflow into n8n

  1. 1Purchase or download the workflow to get the n8n workflow JSON file.
  2. 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
  3. 3Open each node marked with a credential warning and connect your own accounts and API keys.
  4. 4Run the workflow once manually to verify the data flow, then toggle it to Active.

Related Personal workflows

More from BestWorkflows

Need this deployed? We'll set it up for you.

Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.