Slack bot that lets you query a SQLite database using plain English. You type a question with /ask-data, it converts it to SQL using Google Gemini, runs it, and posts the results back in Slack.
- User sends a slash command like
/ask-data total revenue by region last week - LangChain + Gemini turns that into a SQL query against the
sales_dailytable - Query runs on a local SQLite database
- Results come back formatted in Slack
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate a .env file:
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...
GEMINI_API_KEY=your-key-here
Seed the database:
python seed_db.pyRun:
python app.pyapp.py— Slack bot entry point, handles the/ask-datacommandnl_to_sql.py— Converts natural language to SQL using Geminidb.py— Runs queries against SQLiteformatter.py— Formats query results into Slack blocksseed_db.py— Creates and populates the sample database
Single table sales_daily with columns: date, region, category, revenue, orders.
- Python 3.10+
- A Slack app with socket mode enabled and the
/ask-dataslash command configured - Google Gemini API key