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.
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.
New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.
Related bundle
YouTube Creator Pipeline
8 hand-picked workflows for $39.00.
That is $4.88 each, vs $22.99 for this one alone.
View bundleSecure checkout powered by Stripe
Support
How to import this workflow into n8n
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related Personal workflows
- SEO Data Analyst Workflow for E-commerce Insights$24.99
- Automated User Management and Data Processing Workflow$15.04
- AI Agent for Intelligent File Interaction in Supabase and Google Drive$19.99
- Automated Meditation Music Video Creation$19.99
- Instagram Reels Automation: Streamlined Content Creation & Publishing$19.99
- AI Powered Company Research Assistant for Competitive Analysis$19.99
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.