Learn how to deploy a self-hosted AI assistant using this n8n workflow, leveraging the Ollama n8n node and LangChain integration to ensure structured JSON output from Llama 3.2.
Download this n8n workflow template and start using it instantly.
Users interested in leveraging self-hosted, private Large Language Models (LLMs) like Llama 3.
Automation specialists looking for advanced n8n templates for AI integration.
Developers requiring reliable, structured (JSON) output from an AI model.
Anyone needing a robust, local n8n workflow for chat applications.
This comprehensive n8n workflow demonstrates how to create a highly efficient, private AI chat assistant using the self-hosted Ollama platform. The primary challenge solved by this n8n template is ensuring that the LLM's response is consistently formatted as a parsable JSON object, crucial for downstream automation tasks.
By utilizing the LangChain n8n node in conjunction with the Ollama n8n node, this automation guarantees that every chat message received by the n8n trigger is processed by a specific model (Llama 3.2 in this case) and returned in a predetermined format. This powerful setup is ideal for businesses and individuals prioritizing data privacy and requiring predictable data structures from their AI interactions. This specific n8n workflow is a perfect starting point for building sophisticated, localized AI services.
This powerful n8n workflow begins when the When chat message received n8n trigger initiates the process upon receiving a new chat input from a user.
chatInput).llama3.2:latest model.To deploy this specialized n8n workflow, follow these steps:
llama3.2:latest) is pulled and available.This n8n workflow utilizes several key n8n nodes for LLM integration and data manipulation:
When chat message received (Chat Trigger n8n Trigger):
Function: Acts as the starting point, initiating the entire n8n workflow upon receiving a chat message.
Key Configuration: Listens for incoming chat payloads, feeding the chatInput into the next stage.
Basic LLM Chain (LangChain n8n Node):
Function: Orchestrates the AI prompt processing. It uses a custom system prompt to force the LLM to output a JSON string, guaranteeing structure for this n8n workflow.
Key Configuration: Custom prompt definition requesting JSON output. onError is set to 'continueErrorOutput' for robust error handling.
Ollama Model (LangChain Ollama n8n Node):
Function: Connects the n8n workflow to the local Ollama instance, providing the computation power of the LLM.
Key Configuration: Model specified as llama3.2:latest. Requires valid Ollama API credentials.
JSON to Object (Set n8n Node):
Function: Converts the raw JSON string output from the LLM into a structured n8n data object, named response.
Key Configuration: Mapping the incoming text field to a new object field named response using expression {{ $json.text }}.
Structured Response (Set n8n Node):
Function: Formats and finalizes the human-readable output based on the parsed JSON data, completing the n8n workflow cycle.
* Key Configuration: Uses expressions like {{ $json.response.Prompt }} and {{ $json.response.Response }} to create a clean, informative reply.
Use this sophisticated n8n workflow to automatically route user chat prompts to the most appropriate local Ollama LLM (coding, vision, or reasoning) for maximum performance and privacy.

Automate Brazilian PIX QR code generation using this powerful n8n workflow. Integrate payments instantly with custom data processing and external API calls.

Implement robust double opt-in using a core n8n workflow. Verify user emails, store data in Google Sheets, and ensure clean subscriber lists using this reliable n8n template.

Automated system to monitor Meta (Facebook) Ad Account balances using an n8n workflow. Receive real-time low balance alerts via WhatsApp or Gmail to prevent campaign downtime. This n8n template ensures continuous operation.

Analyze n8n community contributor statistics using an advanced n8n workflow and an AI agent. This powerful n8n template fetches leaderboard data from GitHub, filters it by username, and generates a comprehensive Markdown report detailing popular n8n templates and creator impact.

Automate daily news aggregation and classification using this advanced n8n workflow. It scrapes EU news, employs GPT-4o for sustainability classification, archives data in Google Sheets, and sends a curated daily newsletter via the n8n Gmail node.


As an AI Automation consultant based in Canada, I partner with forward-thinking organizations to implement AI solutions that streamline operations and drive growth.







































