AI Agent for Cin7 ERP Data Query via Peliqan Text-to-SQL - n8n Workflow

Use this powerful n8n workflow to create an AI Agent capable of querying Cin7 ERP data via natural language. Integrates n8n nodes for Peliqan and OpenAI for Text-to-SQL automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Business analysts and operations staff needing instant answers from Cin7.
Technical consultants seeking pre-built n8n templates for enterprise data access.
Developers looking to deploy custom internal AI chatbots.
Companies looking to leverage n8n automation for proprietary ERP data querying.

Overview

Accessing real-time, complex business data often requires technical expertise in SQL or navigating slow ERP interfaces. This advanced n8n workflow solves this challenge by deploying an intelligent AI Agent powered by OpenAI and integrated with Peliqan.io, acting as a high-speed data intermediary for Cin7 ERP. This specific n8n template enables users to ask sophisticated business questions in plain English—for example, about inventory levels, sales order statuses, or customer accounts—and receive accurate, summarized data in response. The architecture ensures that the AI Agent has access to the comprehensive Cin7 data model, which is configured directly within the n8n node settings, guaranteeing accurate query formulation. This powerful application of an n8n workflow streamlines decision-making and democratizes data access across the organization, making complex data retrieval easy via a simple chat interface.

How it Works

This comprehensive n8n workflow begins when a user submits a query through the specialized When chat message received n8n trigger. This trigger is designed to initiate the LangChain-based AI process.


  1. Input Reception: The conversation starts when the When chat message received n8n trigger receives the user's question.

  2. AI Agent Processing: The message is immediately passed to the AI Agent n8n node. This node is the core of the intelligent operation. It is configured with an extensive system message detailing the Cin7 ERP schema (tables like cin7omni.salesorders, cin7_omni.products, etc.) and instructions to use the Peliqan tool for data retrieval.

  3. Language and Memory: The AI Agent uses the OpenAI Chat Model n8n node as its language model to determine intent and formulate actions. It maintains context through the Simple Memory n8n node (a Buffer Window) for ongoing conversations.

  4. Tool Use (Text-to-SQL): If the question requires data, the AI Agent decides to use the Execute an SQL query via Peliqan n8n tool. It generates the necessary SQL query based on the system instructions and the Cin7 data model provided.

  5. Data Execution: The Peliqan n8n node receives the generated SQL query and executes it against the synchronized Cin7 data warehouse, rapidly retrieving the results.

  6. Final Synthesis: The query results are returned to the AI Agent n8n node, which then interprets the raw data and formulates a human-readable, conversational answer, completing the cycle of this robust n8n workflow.

Installation Guide

To deploy this powerful n8n template, follow these steps:


  1. Import: Copy the provided n8n workflow JSON and paste it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Peliqan Setup: Sign up for Peliqan.io and connect your Cin7 ERP instance to their data warehouse. Obtain your Peliqan API key from Settings > API key.

  3. Peliqan Credentials in n8n: Create new Peliqan credentials in n8n using your API key. Update the 'Execute an SQL query via Peliqan' n8n node to use these credentials and select the correct data warehouse name.

  4. OpenAI Credentials: Set up your OpenAI API key credentials within n8n. Configure the 'OpenAI Chat Model' n8n node to use these credentials.

  5. Tool Usage Environment Variable: Crucially, since this n8n workflow uses the AI Agent to dynamically call a tool (the Peliqan n8n node), you must set the environment variable: export N8NCOMMUNITYPACKAGESALLOWTOOL_USAGE=True in your n8n environment to allow the LangChain agent functionality to work correctly.

  6. Activation: Ensure the n8n workflow is active, and use the URL provided by the 'When chat message received' n8n trigger to access your new AI chatbot.

Node Details

This n8n workflow leverages several specialized n8n node types to achieve sophisticated AI automation:

When chat message received (n8n Trigger):
Function: Serves as the conversational entry point, acting as the n8n trigger that listens for user input messages.
Key Configuration: Configured as a public webhook to start the chat interaction.

AI Agent (LangChain Agent n8n Node):
Function: The central intelligence unit. It processes the user query, determines if an external tool (Peliqan) is required, and constructs the necessary action (generating SQL).
Key Configuration: Contains an extensive System Message which defines the agent's persona and includes the complete data model (tables and columns) for Cin7 ERP, ensuring the generated SQL is accurate and functional.

OpenAI Chat Model (LLM n8n Node):
Function: Provides the language processing power for the AI Agent, converting natural language into tool inputs (SQL queries) and synthesizing results back into natural language outputs.
Key Configuration: Uses predefined OpenAI credentials.

Simple Memory (LangChain Memory n8n Node):
Function: Manages the history of the conversation, allowing the AI Agent to maintain context and refer back to previous user inputs.
Key Configuration: Standard Buffer Window memory configuration.

Execute an SQL query via Peliqan (Peliqan Tool n8n Node):
Function: Acts as the specialized n8n tool for the AI Agent. It executes the dynamically generated SQL query against the Peliqan data warehouse which holds the mirrored Cin7 ERP data.
* Key Configuration: The querySql parameter is dynamically mapped to accept the SQL query generated by the AI Agent: ={{ $fromAI('SQL_Query', '', 'string') }}. Requires Peliqan credentials setup.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

Peliqan.io is the one-click data foundation for our n8n AI Agents. Add all your business applications for RAG and "Text to SQL", and build AI chatbots and AI Agents that can interact with all internal company data from CRM, ERP, cloud storage, accounting, HRM/ATS etc.

Featured*