Build Custom AI Agent with LangChain & Gemini (Self-Hosted) — n8n Workflow
Overview
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).
Setup Instructions
Configure Gemini Credentials: Set up your Google Gemini API key (Get API key here if needed). Alternatively, you may use other AI provider nodes.
Interacti
Nodes used
Workflow Preview
How it Works
- 1
Trigger
The workflow starts with a trigger trigger.
- 2
Process
Data flows through 4 nodes, connecting chattrigger, code, lmchatgooglegemini.
- 3
Output
The workflow completes its automation and delivers the result to the configured destination.
Node Details (4)
LangChain Code
n8n-nodes-langchain.code
Simple Memory
n8n-nodes-langchain.memoryBufferWindow
Google Gemini Chat Model
n8n-nodes-langchain.lmChatGoogleGemini
How to Import This Workflow
- 1Click Download JSON button on the right to save the workflow file.
- 2Open your n8n instance. Go to Workflows → New → Import from file.
- 3Select the downloaded
build-custom-ai-agent-with-langchain-gemini-self-hostedfile and click Import. - 4Set up credentials for each service node (API keys, OAuth, etc.).
- 5Click Test Workflow to verify everything works, then activate it.
Or paste directly in n8n → Import from JSON:
Integrations
Created by
shepard
@shepard
Tags
New to n8n?
n8n is a free, open-source workflow automation tool. Self-host it or use the cloud version.
Get n8n Free →