Use this powerful n8n workflow to monitor and trace all Gemini 2.5 chat interactions using Langfuse observability. Essential for debugging custom n8n templates and analyzing AI performance.
Download this n8n workflow template and start using it instantly.
AI Developers needing robust observability tools for their production LLM applications.
Data Scientists and MLOps Engineers who require detailed tracing of conversational flow and token usage.
Users building complex conversational systems using n8n templates and the Langchain integration.
Anyone leveraging the Google Gemini API within an n8n workflow who needs performance monitoring.
Developing reliable AI applications requires more than just calling an API; it demands deep visibility into how the models process inputs and generate outputs. This specialized n8n workflow template addresses the critical need for observability by integrating Langfuse tracing directly into the conversational pipeline powered by Google Gemini 2.
5.
This robust solution allows you to capture every detail of the chat session, including context, token usage, and latency, which is essential for debugging, cost optimization, and improving model performance. By utilizing a custom n8n node to inject the Langfuse callback handler, this n8n workflow ensures that your Langchain-based AI Agent is fully instrumented from the moment the conversation begins. This provides the necessary tools for professional monitoring, making this one of the most valuable n8n templates for serious AI development.
The entire process starts with the primary n8n trigger, the When chat message received n8n node, which initiates the conversation when a new message arrives via a webhook. This message is passed directly to the AI Agent n8n node, which handles the orchestration of the LLM and memory components.
The core intelligence is the gemini-2.5 n8n node, which defines the underlying language model (Gemini 2.5 Flash). Instead of connecting directly to the Agent, this model is piped into the Langfuse LLM custom code n8n node.
Inside the Langfuse LLM n8n node, a custom script takes the Gemini model object and dynamically wraps it with the Langfuse CallbackHandler, using the sessionId provided by the initial n8n trigger data. This creates an instrumented LLM.
This newly instrumented model is then provided to the AI Agent n8n node. Concurrently, the mem (Buffer Window Memory) n8n node is connected to the Agent, providing conversational context. The AI Agent utilizes the traced Gemini model and the conversation history to generate a response, ensuring every step of the processing is automatically logged and sent to your Langfuse dashboard for detailed analysis.
LANGFUSEPUBLICKEY, LANGFUSESECRETKEY, and LANGFUSE_HOST) to be configured on your n8n host environment, allowing the custom code n8n node to successfully send traces. When chat message received (n8n trigger):
Function: Serves as the starting n8n trigger, initiating the automation when an external chat message is received via a unique webhook.
Key Configuration: Provides necessary input data, including the sessionId used later by the Langfuse code for tracing context.
gemini-2.5 (LLM Chat Google Gemini n8n node):
Function: Defines the core Large Language Model used for generating responses.
Key Configuration: Uses models/gemini-2.5-flash-preview-05-20 and sets the generation temperature to 0.4.
Langfuse LLM (Langchain Code n8n node):
Function: This is the critical custom n8n node responsible for instrumenting the LLM. It imports the Langfuse callback handler, initializes it using the input sessionId, and wraps the incoming Gemini model, ensuring all subsequent calls are traced by Langfuse.
Key Configuration: Custom JavaScript code handles the model wrapping and callback injection.
mem (Memory Buffer Window n8n node):
Function: Maintains conversational history for the AI Agent.
Key Configuration: Configured with a context window length of 100 tokens/messages.
AI Agent (Langchain Agent n8n node):
Function: The central orchestration unit. It receives the chat message, utilizes the instrumented LLM (from the Langfuse LLM node), and leverages the provided memory to formulate the final, context-aware response. This powerful n8n node completes the conversational loop.
Automate Shopify review processing using an n8n workflow. Analyze sentiment with GPT-4, create Trello tasks for critical reviews, and log all data to Google Sheets efficiently.

Automate Google Maps review monitoring using an n8n workflow. Scrape new reviews, use AI to draft replies, save to Google Sheets, and send instant Slack alerts for negative feedback.

Leverage this powerful n8n workflow to monitor Docker containers via webhooks and manage them using a Telegram bot. Features AI-powered log analysis via OpenAI and remote SSH commands.

Automate daily ArXiv AI paper filtering, ranking, and summarization using a powerful n8n workflow and Gemini models. Get only the most relevant, actionable insights via email.

Use this powerful n8n workflow to automatically monitor critical travel APIs like Amadeus and Booking.com for uptime and SLA compliance, triggering immediate alerts via WhatsApp using the dedicated n8n node.


Full Stack Developer with 8+ years building web applications, now focused on AI engineering and cybersecurity. I integrate LLMs into production systems, conduct security audits, and help teams build safer, smarter software. Particularly interested in making AI applications both powerful and secure.







































