Build an AI Data Analyst Inside Slack
Bridge the gap between your team and your data with one Slack DM.
Most teams need data to move fast, but access is slow, messy, or locked behind tools they don’t use. Slack is where work happens — so it should be where data lives too.
This guide shows how to connect Slack to your Bag of Words deployment, so you can query your database using plain language, right inside a Slack DM. It’s fast, simple, and doesn’t break your workflow.
Queries go through your LLM, hit your actual data source, and return results directly in Slack — with proper user authentication and audit logs by default.
No dashboards. No tabs. Just accurate data, where you already are.
What You'll Build: DM a bot in Slack with questions like “show churn rate by plan tier over last 6 months” and get responses like “Here’s your chart. Also saved a report to your Bag of Words dashboard.”
Architecture Overview
The architecture is straightforward - Bag of words handles the core functionality of connecting to your data sources, managing the LLM interactions, and maintaining relevant business context and language. We then leverage Bag of words' native Slack integration to seamlessly connect with your Slack workspace. Below you'll find a detailed step-by-step guide to set this up.
Step 0: Deploy Bag of Words
Start by deploying Bag of Words. It’s self-hosted and deploys easily via Docker or Helm.
Install instructions: https://docs.bagofwords.com/install
Once deployed, log into the web UI, connect an LLM, then add your data source, and set up your admin account. Natural language querying in the UI should work out of the box.
Step 1: Add an LLM
Bag of Words needs an LLM to convert natural language into SQL or API calls. Navigate to Settings → LLM Provider → Add Key
. Plug in your LLM provider OpenAI, Anthropic, or others with your API key.
Once added, all queries will route through the LLM before being executed.
Step 2: Connect Your Database
Go to Data Sources
. Choose from Postgres, MySQL, BigQuery, Snowflake, Salesforce, AWS Cost, or others.
Test a query like: > "total active users by week for last 90 days"
. If that works, your pipeline is healthy.
Step 3: Set up the Slack Integration
Now you’ll create a Slack App and hook it into your Bag of Words backend so Slack can act as a frontend for queries. Go to Slack API Dashboard → “Create New App from Scratch”.
3.1 Create the App:
Name it (e.g., Data Assistant) and assign it to your workspace.
3.2 Set Permissions: Add these Bot Token Scopes in OAuth & Permissions
:
app_mentions:read channels:read chat:write files:read files:write im:history im:read im:write reactions:read users:read users:read.email
Click "Install to Workspace" and copy the Bot Token (starts with xoxb-
).
3.3 Set Up Webhook: Enable Event Subscriptions. Use this request URL:
https://your-bagofwords-url.com/api/settings/integrations/slack/webhook
Add the event message.im
so the bot can receive DMs.
3.4 Get Signing Secret: Under Basic Information in your Slack App settings, copy the Signing Secret.
3.5 Connect in Bag of Words: Go to Settings → Integrations → Slack → Connect
and paste the Bot Token and Signing Secret.
Click "Connect" — Slack should now be wired up.
Step 4: Authenticate Slack Users
To ensure security, especially when data is involved, users must be Bagofwords users, and once messaging the bot, the user will be prompted to login with their Bagofwords account. Once logged in, the user will be able to chat with the bot.
Step 5: Use It
Now anyone can ask data questions in Slack DMs:
> "weekly signup count by channel since March"
> "top 10 pages by bounce rate"
> "generate csv of sales by product line, Q1"
The bot replies with answers, charts, downloadable files, and a saved report link.
Why This Matters
This removes friction between question and answer. No dashboards. No waiting. Just Slack as a data interface. It democratizes insight without creating chaos.
Final Thoughts
This isn’t a gimmick. It’s an actual workflow shift. If your team lives in Slack, this gives them instant access to real-time data — securely and repeatably.
Got feedback? Contribute on GitHub.