n8n

How to Connect OpenAI with SQLite Data Insights?

Turn your SQLite data into a simple chat experience. Team members can ask questions in plain English and get answers from the database without writing SQL. Great for quick checks, ad hoc reports, and follow up questions in one place.

Behind the scenes, a manual step downloads and saves a sample SQLite file once. Each chat message then loads the local database, merges the chat JSON with the database file, and sends both to an AI SQL Agent powered by OpenAI. The agent can run several SQL queries to build the final answer. A memory buffer keeps the last 10 messages so follow up questions keep context.

You only need an OpenAI API key and access to n8n. Run the one time setup to fetch and store the database file, then start chatting with the data. Expect faster answers, fewer analyst requests, and better focus for your team. Helpful use cases include sales summaries, product counts, catalog lookups, and quick revenue snapshots.

What are the key features?

  • Manual trigger downloads a sample ZIP, extracts it, and saves a local SQLite file
  • Local file handling loads the database on every chat message
  • Chat Trigger receives user input as JSON for each conversation
  • Set node combines the chat JSON with the SQLite binary so the agent can read it
  • AI Agent uses a SQL Agent configured for SQLite to run queries
  • OpenAI Chat Model with temperature 0.3 for steady, focused answers
  • Memory buffer window stores the last 10 messages for context and follow ups
  • Agent can run several SQL queries before returning a final answer

What are the benefits?

  • Reduce manual data lookups from 1 hour to 2 minutes
  • Automate up to 80 percent of ad hoc reporting questions
  • Eliminate most copy and paste errors by querying the source directly
  • Support up to 10 follow up turns with built in chat memory
  • Connect OpenAI and SQLite without writing any SQL

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. In your OpenAI account, create an API key on the API Keys page and copy it.
  4. In the n8n credentials manager, create a new OpenAI credential. Paste your API key, name the credential clearly, and save.
  5. Open the OpenAI Chat Model node and select your OpenAI credential. Confirm the model is set to gpt-4-turbo and temperature is 0.3.
  6. Run the one time data setup: click Test workflow on the manual trigger. This downloads the sample ZIP, extracts it, and saves chinook.db locally.
  7. Verify the file was saved: open the execution details for the Save file node and confirm ./chinook.db exists with a binary attached.
  8. Open the Chat Trigger node and start a test session. Send a message like Please describe the database to confirm the agent can read the file.
  9. Ask a follow up like What are the revenues by genre to see multiple agent actions and memory across turns.
  10. Troubleshooting: if tables are not found, check that Load local sqlite points to ./chinook.db and that the Combine chat input with the binary node has include binary enabled. If answers seem random, lower the temperature or verify your OpenAI key is active.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.