Animated data flow diagram

AI Chat Data Extractor Agent using Ollama & Mistral NeMo

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

Ollama Langchain

Overview

Unlock Automated Data Entry from Chats with this AI Agent

This n8n workflow acts as an AI Agent specialized in understanding and extracting structured personal information from unstructured chat messages. It leverages the power of a locally-hosted Mistral NeMo model through Ollama, giving you full control over your data and AI operations. Once a chat message is received, the agent processes the text, identifies key data points according to a predefined JSON schema, and outputs them in a structured format. It even includes an auto-fixing mechanism to improve the reliability of the LLM's output.

Key Features & Benefits

  • AI-Driven Data Extraction: Utilizes the Mistral NeMo LLM for sophisticated natural language understanding to pull specific personal data (e.g., name, surname, communication type, contacts, timestamp, subject).
  • Self-Hosted & Private: Runs on your own Ollama instance with Mistral NeMo, ensuring sensitive chat data never leaves your infrastructure.
  • Structured Output: Employs a Langchain Structured Output Parser to transform extracted data into a clean, ready-to-use JSON format based on your custom schema.
  • Intelligent Auto-Correction: Features an Auto-fixing Output Parser that re-prompts the LLM if the initial output doesn't meet schema requirements, enhancing accuracy.
  • Chat-Triggered Automation: Activates automatically when a new chat message is received, ready to integrate with various chat platforms or webhook sources.
  • Customizable Extraction Schema: Easily define what specific pieces of information you want to extract by modifying the JSON schema within the workflow.

Use Cases

  • Automating lead data capture from website chat widgets directly into your sales pipeline.
  • Streamlining customer support by extracting issue details and contact info from support chat transcripts for CRMs.
  • Parsing user registration details provided in a conversational format via a chatbot.
  • Gathering structured feedback or specific data points from user comments in community chat platforms.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • Ollama installed and running, accessible by your n8n instance.
  • The mistral-nemo:latest model (or your chosen Mistral variant) pulled in Ollama (e.g., ollama pull mistral-nemo).
  • Ollama API credentials configured within your n8n instance.
  • A configured 'When chat message received' (Chat Trigger) node (e.g., connected to a webhook for your chat platform).

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure the 'When chat message received' node: Set up the webhook or connection to your chat input source.
  4. Configure the 'Ollama Chat Model' node:
    • Select your pre-configured Ollama API credentials.
    • Ensure the model parameter is set to mistral-nemo:latest (or the specific self-hosted model tag you're using in Ollama).
    • Adjust keepAlive, temperature, and other options as needed for your Ollama setup and desired output.
  5. Customize the 'Structured Output Parser' node:
    • Modify the inputSchema (JSON schema) to define the exact data fields (e.g., name, email, phone, company, inquiry_type) you need the AI Agent to extract.
  6. Review and optionally refine the prompt in the 'Basic LLM Chain' node. The default prompt is: Please analyse the incoming user request. Extract information according to the JSON schema. Today is: "{{ $now.toISO() }}". Tailor this for better performance with your specific data and schema.
  7. The workflow includes an 'Auto-fixing Output Parser'. If the LLM's initial response doesn't match the schema, this node attempts a correction using the same LLM.
  8. The 'Extract JSON Output' node provides the structured data. Connect subsequent n8n nodes here to process this data (e.g., add to a Google Sheet, create a CRM record, send a notification).
  9. Activate the workflow and test thoroughly with various sample chat messages to ensure accuracy.

Tags:

AI AgentData ExtractionOllamaMistralNLPAutomationSelf-Hosted AILangchainChat Automation

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation