Build an AI Data Analyst Inside Slack

How to build a data AI analyst inside Slack using Bag of words.

5 min read

If you’ve ever tried getting quick answers from your data, you know the drill: switch tabs, open a dashboard, remember which filter does what, export to CSV, maybe ping someone on the data team. It’s slow and annoying.

Your team already lives in Slack. So why not just ask your database questions there?

That’s what this guide is about. We’re going to hook up Slack to Bag of Words so you can DM a bot with questions like “show churn rate by plan tier over last 6 months” and get back actual answers with charts.

Slack Bot Example

Here’s what happens: you ask a question in plain English, the LLM converts it to SQL, runs it against your actual database, and sends back the result. All in Slack. Auth and audit logs included.

How It Works

It’s pretty simple. Bag of Words connects to your database and handles all the LLM stuff. Then we wire up Slack to talk to Bag of Words. That’s it.

Slack Architecture

Step 0: Deploy Bag of Words

First, get Bag of Words running. You can spin it up with Docker or Helm — full instructions at docs.bagofwords.com/install.

Once it’s up, log in, add an LLM, connect your database, and create your admin account. If you can ask questions in the web UI and get answers back, you’re good.

Step 1: Add an LLM

Go to Settings → LLM Provider → Add Key and plug in your API key. Works with OpenAI, Anthropic, or whatever else you’re using. This is what translates “show me revenue” into actual SQL.

Step 2: Connect Your Database

Head to Data Sources and pick yours — Postgres, MySQL, BigQuery, Snowflake, Salesforce, AWS Cost Explorer, whatever.

Try asking something like "total active users by week for last 90 days". If it works, you’re set.

Step 3: Set up the Slack Integration

Now we need to create a Slack app and connect it to Bag of Words.

Go to api.slack.com/apps and click “Create New App from Scratch”. Name it something like Data Assistant and pick your workspace.

Add Permissions

Under OAuth & Permissions, add these Bot Token Scopes:

app_mentions:read
channels:read
chat:write
files:read
files:write
im:history
im:read
im:write
reactions:read
users:read
users:read.email

Hit “Install to Workspace” and grab your Bot Token (the one that starts with xoxb-).

Set Up the Webhook

Go to Event Subscriptions and turn it on. For the Request URL, use:

https://your-bagofwords-url.com/api/settings/integrations/slack/webhook

Add the message.im event so your bot can actually read DMs.

Get Your Signing Secret

Under Basic Information, copy the Signing Secret.

Connect Everything

Back in Bag of Words, go to Settings → Integrations → Slack → Connect. Paste in your Bot Token and Signing Secret.

Slack Token Configuration

Hit “Connect” and you’re done with setup.

Step 4: User Authentication

For security (because this is real data), people need to be Bag of Words users. When someone DMs the bot for the first time, they’ll be asked to log in. After that, they can just ask questions.

Step 5: Actually Use It

That’s it. Now anyone on your team can DM the bot:

> "weekly signup count by channel since March"
> "top 10 pages by bounce rate"
> "generate csv of sales by product line, Q1"

They get back answers, charts, CSV files, and a link to the saved report.


Why bother with this? Because context switching kills momentum. Opening a BI tool, finding the right dashboard, remembering how filters work — it takes time and most people just give up.

With this setup, data is where conversations already happen. Someone asks a question in a thread, you can reply with actual numbers without leaving Slack.

That’s the whole point. Less friction, faster answers, same security.

If you have thoughts or want to contribute, we’re on GitHub.