Choose an available topic from the sidebar. More documentation is coming soon.

Advanced

Convert CSV to SQLite for Your Chatbot

Convert your CSV or Excel data to a SQLite database that your chatbot can query for accurate responses.

The best way to improve the accuracy of your chatbot’s responses when dealing with structured data in CSV or Excel format is to import the data into a SQLite database. Your chatbot can then query this database directly using the SQLite Database action.

Why Use SQLite Instead of CSV?

Feature

Data accuracy

CSV Training

May misinterpret rows

SQLite Action

Precise SQL queries

Large datasets

Limited

Handles large tables

Updates

Retrain required

Just upload new DB

Complex queries

Not supported

Full SQL support

Filtering/sorting

Basic

Advanced

MCP Server and WebMCP are available on Pro, Pro Plus, and Business plans. Each plan includes a monthly query allowance (Pro: 1,000 / Pro Plus: 2,500 / Business: 10,000).

Creating the SQLite Database

1

Install SQLite

Ensure you have sqlite3 installed on your system. It comes pre-installed on macOS and most Linux distributions.

2

Create a new database

Open your terminal and run:
				
					sqlite3 my_data.db
				
			

Replace my_data.db with your preferred database name.

Importing Your CSV Data

In the SQLite prompt that opens, run the following commands:

				
					-- Enable CSV import mode
.mode csv

-- Import your CSV file into a table
.import /path/to/your/data.csv table_name
				
			

Each CSV file will become a separate table in your database. You can import multiple CSV files to create multiple tables.

Example

				
					-- Import products data
.mode csv
.import /Users/me/products.csv products

-- Import orders data
.import /Users/me/orders.csv orders
				
			

Verify Your Data

Check that the table was created correctly:

				
					-- View the table schema
.schema products

-- Preview the data
SELECT * FROM products LIMIT 5;
				
			

Check Column Types

It’s important to verify that columns have the correct data types, especially for numeric fields used in sorting or calculations.

				
					-- Check if price is being treated as a number
SELECT typeof(price) FROM products LIMIT 1;
				
			

If columns have wrong types, you may need to recreate the table with explicit types:

				
					-- Create table with correct types
CREATE TABLE products_new (
  id INTEGER PRIMARY KEY,
  name TEXT,
  price REAL,
  stock INTEGER
);

-- Copy data
INSERT INTO products_new SELECT * FROM products;

-- Replace old table
DROP TABLE products;
ALTER TABLE products_new RENAME TO products;
				
			

Add the SQLite Action to Your Chatbot

1

Go to Tools & Actions

In your chatbot dashboard, click Configuration then Tools & Actions.

2

Add SQLite Database Action

Click + Add Action and select SQLite Database.

3

Configure the Action
  • Give it a descriptive Name (e.g., product_database)
  • Add a Description explaining what data it contains and when to use it
  • Upload your .db file

4

Save

Click Add Action to enable it.

Your chatbot will now use the database to answer visitor questions about your data.

Add specific instructions in the Description field, such as: “Use this database when users ask about product availability, pricing, or specifications. The products table contains columns: id, name, price, stock, category.”

Updating Your Database

When your data changes, simply:

  1. Update your local SQLite database file
  2. Go to Tools & Actions in your chatbot dashboard
  3. Edit the SQLite Database action
  4. Upload the new database file

You can use a GUI tool like TablePlus or DB Browser for SQLite to edit your database visually.

Best Practices

Use Clear Column Names

				
					-- Good: Clear, descriptive names
CREATE TABLE products (
  product_id INTEGER,
  product_name TEXT,
  unit_price REAL,
  in_stock INTEGER
);

-- Avoid: Ambiguous names
CREATE TABLE products (
  id INTEGER,
  n TEXT,
  p REAL,
  s INTEGER
);
				
			

Add Helpful Descriptions

In your action description, tell the chatbot about:

Test Common Queries

Before going live, test that your chatbot can answer typical questions:

Ready to automate your customer service with AI?

Join over 1000+ businesses, websites and startups automating their customer service and other tasks with a custom trained AI agent.

On this page