workflows.fit
Back to n8n workflows
n8n templateFreeBy Peliqan

Query business data with OpenAI chatbot using RAG and text-to-SQL via Peliqan

![Peliqan n8n chatbot with RAG and Text-To-SQL](https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/99465134-7cb5-46cd-a26c-c44c11a3317e/Peliqann8nAIAgenttemplatewithRAGandTexttoSQL/w=1920,quality=90,fi...

AILangchainCore NodesChat TriggerAgentLm Chat Open AiEmbeddings Open Ai
Loading interactive preview...

Template notes

![Peliqan n8n chatbot with RAG and Text-To-SQL](https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/99465134-7cb5-46cd-a26c-c44c11a3317e/Peliqann8nAIAgenttemplatewithRAGandTexttoSQL/w=1920,quality=90,fit=scale-down)

How it works

This template is an end-to-end demo of a chatbot using business data from multiple sources (e.g. Notion, Chargebee, Hubspot etc.) with RAG + SQL.

Peliqan.io is used as a "cache" of all business data. Peliqan uses one-click ELT to sync all your business data to its built-in data warehouse, allowing for fast & accurate RAG and "Text to SQL" queries.

The workflow will write source data to Supabase as a vector store, for RAG searches by the chatbot. The source URL (e.g. the URL of a Notion page) is added in metadata.

The AI Agent will decide for each question to use either RAG or Text-to-SQL or a combination of both. Text-to-SQL is performed via the Peliqan node, added as a tool to the AI Agent. The question of the user in natural language is converted to an SQL query by the AI Agent. The query is executed by Peliqan.io on the source data and the result is interpreted by the AI Agent.

RAG is typically used to answer knowledge questions, often on non-structured data (Notion pages, Google Drive etc.). Text-to-SQL is typically used to answer analytical questions, for example "Show list of customers with number of open support tickets and add customer revenue based on invoiced amounts".

Preconditions