Advanced
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.
Data accuracy
May misinterpret rows
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
Install SQLite
Ensure you have sqlite3 installed on your system. It comes pre-installed on macOS and most Linux distributions.
Create a new database
sqlite3 my_data.db
Replace my_data.db with your preferred database name.
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
-- Import products data
.mode csv
.import /Users/me/products.csv products
-- Import orders data
.import /Users/me/orders.csv orders
Check that the table was created correctly:
-- View the table schema
.schema products
-- Preview the data
SELECT * FROM products LIMIT 5;
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;
In your chatbot dashboard, click Configuration then Tools & Actions.
Add SQLite Database Action
Click + Add Action and select SQLite Database.
Click Add Action to enable it.
When your data changes, simply:
You can use a GUI tool like TablePlus or DB Browser for SQLite to edit your database visually.
-- 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
);
In your action description, tell the chatbot about:
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.