π Talk to your SQLite database with a LangChain AI Agent π§ π¬
β‘ 26,939 views Β· π Internal Wiki & Knowledge Base
Description
This n8n workflow demonstrates how to create an agent using LangChain and SQLite. The agent can understand natural language queries and interact with a SQLite database to provide accurate answers. πͺ
π Setup
Run the top part of the workflow once.
It downloads the example SQLite database, extracts from a ZIP file and saves locally (chinook.db).
π£οΈ Chatting with Your Data
- Send a message in a chat window.
- Locally saved SQLite database loads automatically.
- Userβs chat input is combined with the binary data.
- The LangChain Agend node gets both data and begins to work.
The AI Agent will process the userβs message, perform necessary SQL queries, and generate a response based on the database information. ποΈ
π Example Queries
Try these sample queries to see the AI Agent in action:
- βPlease describe the databaseβ - Get a high-level overview of the database structure, only one or two queries are needed.
- βWhat are the revenues by genre?β - Retrieve revenue information grouped by genre, LangChain agent iterates several time before producing the answer.
The AI Agent will store the final answer in its memory, allowing for context-aware conversations. π¬
Read the full article: π https://blog.n8n.io/ai-agents/
π Nodes Used
HTTP Request, AI Agent, OpenAI Chat Model, Simple Memory, Read/Write Files from Disk, Chat Trigger
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File