n8nSalesRevenue growthAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

Build an n8n + Peliqan RAG + Text-to-SQL Business Data Chatbot

Input: multi-source business data (CRM/Notion/ERP) → Process: Peliqan sync + Supabase vector store + AI Agent routing → Output: natural-language query answers

ExperiencedStepsWorkflowPromptTip
Who
Teams needing an AI chatbot in n8n that can query internal business data
You get
Users ask in natural language; AI Agent automatically chooses RAG (knowledge retrieval) or Text-to-SQL (data analytics)
You need
n8n · supabase · peliqan

Constraints

Requires n8n self-hosted (community node restriction). Prerequisites: Peliqan.io free trial, at least one business data source (Hubspot/Pipedrive/Notion/etc.), Supabase project, OpenAI API Key. Set N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=True on self-hosted environment. Costs: OpenAI API usage-based; Peliqan/Supabase have free tiers.

What they did

Peliqan published an end-to-end template on the n8n official template library demonstrating how an AI Agent can query multi-source business data via both RAG and Text-to-SQL. Peliqan acts as a data cache layer, syncing CRM, ERP, Notion, etc. into its built-in warehouse via one-click ELT; the n8n workflow writes source data into a Supabase vector store for RAG retrieval and mounts a Peliqan SQL query tool to the AI Agent.

How it went

The source reports this template can answer knowledge questions via RAG (based on unstructured data like Notion) and analytics questions via Text-to-SQL (e.g. 'Show list of customers with number of open support tickets and add customer revenue based on invoiced amounts'). The AI Agent automatically decides which approach to use, or a combination. (author_report)

Worth knowing

1. This template contains a community node and only works for n8n self-hosted, not n8n Cloud. 2. The AI Agent systemMessage ends with '(etc. truncated)' in the source; the full data model must be completed by the user based on actual Peliqan tables. 3. The vector store defaults to Supabase table 'documents'; confirm the table exists and pgvector is enabled. 4. No specific cost estimate is provided in the source; OpenAI API, Peliqan, and Supabase may incur charges. 5. This workflow has not been tested by our site (reproduction=not_tested).

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • OpenAI Chat Model node: connect OpenAI API credentials.
  • Embeddings OpenAI for RAG retrieval node: connect OpenAI API credentials.
  • Supabase Vector Store to store vectors for RAG node: connect supabaseApi credentials.
  • Get table data node: connect peliqanApi credentials.
  • Execute an SQL query via Peliqan node: connect peliqanApi credentials.
  • Supabase Vector Store for search node: connect supabaseApi credentials.
  • Embeddings OpenAI for RAG node: connect OpenAI API credentials.

Configuration to replace

  • Source template is n8n public workflow #6706 (~19 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-24

Steps

  1. Prepare Peliqan account and data sources

    Sign up for a free trial at peliqan.io. Add one or more business data sources in Peliqan (e.g. Hubspot, Pipedrive, Notion). Peliqan syncs data to its built-in warehouse via one-click ELT.

  2. Configure n8n credentials and self-hosted environment

    Configure three credential types in n8n: openAiApi (OpenAI API Key), supabaseApi (Supabase project URL and service key), peliqanApi (API Key from Peliqan Settings). **Self-hosted n8n only**: set environment variable `export N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=True` on the server/container running n8n, otherwise the Peliqan node cannot be used as an AI Agent tool.

    Setup guidance · Source text。Environment variable for n8n self-hosted server

    export N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=True
  3. Run data sync workflow to populate vector store

    Manually execute the 'When clicking Execute workflow' branch: Peliqan node 'Get table data' pulls from a specified table → Default Data Loader joins title and content into documents → Recursive Character Text Splitter (chunkSize=500, chunkOverlap=100) splits text → Embeddings OpenAI generates vectors → inserts into Supabase Vector Store (table 'documents', metadata includes source_url and title). Change the tableId in 'Get table data' if using a different source table.

    Execution prompt · Source text。Default Data Loader node jsonData expression field

    =# {{ $json.title + '\n' + $json.content }}
  4. Configure AI Agent system message and data model

    Open the AI Agent node's System Message. Keep the role definition and tool usage instructions. Replace the example schema under 'This is the data model of tables & columns' with your actual Peliqan source tables and columns. The source example includes chargebee.customers, chargebee.credit_notes, chargebee.invoices, etc., but your environment needs the real schema.

    Execution prompt · Source text。AI Agent node System Message field; note source is excerpt, replace with full data model in production

    You are an assistant answering questions on internal business data.
    
    You can use the Vector Store to find info, which contains all pages of Notion (intranet) with internal knowledge.
    
    You can also run SQL queries for quantitive questions on tables. To execute an SQL query: send the query to Peliqan tool "Execute SQL" in a key SQL_Query__View_. Get the results from key "detail".
    
    This is the data model of tables & columns that can be used in SQL queries:
    
    Columns in table chargebee.customers:
    
    customer_id
    customer_first_name
    customer_last_name
    customer_email
    customer_phone
    
    Columns in table chargebee.credit_notes:
    
    credit_note_id
    credit_note_customer_id
    credit_note_subscription_id
    credit_note_reference_invoice_id
    credit_note_type
    
    Columns in table chargebee.invoices:
    
    invoice_id
    invoice_customer_id
    invoice_subscription_id
    
    (etc. truncated)
  5. Activate workflow and start chatting

    Save and activate the workflow. Send messages via the 'When chat message received' trigger public URL or n8n's built-in Chat interface. The AI Agent routes by question type: knowledge questions call Supabase Vector Store (RAG), analytics questions call Peliqan Execute SQL tool (Text-to-SQL), or a combination. Simple Memory maintains conversation context.

Prompt you can copy

Setup guidance · Editorial suggestion。Setup assistant kickoff prompt; guides credential configuration and environment preparation in sequence

This block is the prompt. Ads are never placed here.

After importing this template into n8n, configure Peliqan, Supabase, and OpenAI credentials in order, set the self-hosted environment variable, replace the data model schema in the AI Agent, then activate the workflow to start testing.

Note: Peliqan is a community node and requires self-hosted n8n with N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=True enabled.

Source

Query business data with OpenAI chatbot using RAG and text-to-SQL via Peliqan · peliqan · n8n.io · 2025-07-30

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related