Slack data Q&A bot powered by Snowflake
Let your team ask data questions in Slack and get answers from your Snowflake warehouse, with the SQL shown for review.
Build an agent workflow that lets my team ask data questions in Slack in plain English and answers them from my Snowflake warehouse.
Trigger: a Slack webhook on app_mention events. The agent should run whenever the bot is @-mentioned in a designated Slack channel. I will pick the channel during setup.
On each mention, the agent should do the following:
1. Read the user's question from the Slack event, stripping the bot mention so only the actual question text remains.
2. Use a schema description I will paste into the prompt as the source of truth for what tables and columns exist. The schema description lists table names, column names, types, and short business definitions. The agent must not invent tables or columns that are not in that description. If the question references something not covered, it should say so in the thread instead of guessing.
3. Generate a single safe, read-only SQL query for Snowflake. Hard rule: the query must be exactly one SELECT statement. The agent must refuse anything that includes INSERT, UPDATE, DELETE, MERGE, CREATE, DROP, ALTER, TRUNCATE, GRANT, REVOKE, COPY, PUT, REMOVE, multi-statement requests, or a CTE that wraps a write. If the question cannot be answered safely with a SELECT, the agent should reply with a short refusal in the same thread.
4. Run the query against Snowflake using the Execute SQL Statement operation. Pass the configured database, schema, warehouse, and role. Always add a LIMIT to non-aggregate queries (default 100, configurable). Use bind variables for any user-supplied literals.
5. Inspect the result. If it returned more rows than the configured limit, do not dump the rows. Instead, reply with a clarifying question in the thread suggesting a tighter filter or an aggregation, for example: "That returned about 8,400 rows. Want me to aggregate by month, or filter to the last 30 days?"
6. Otherwise, reply in the same Slack thread using the Send a Message operation. The reply should include: a one or two sentence natural-language summary of the answer; a clean Slack mrkdwn table for small row sets, or a single highlighted value for single-number answers; the exact SQL it ran inside a code block so analysts can sanity-check; and a note with the row count if results were truncated.
7. If Snowflake returns an error, reply in the thread with the human-readable error message (not the raw JSON) and a brief suggestion for a likely fix, for example a misspelled column name or a missing warehouse.
Configurable inputs the user fills in once during setup:
- Slack channel ID where the bot listens and replies.
- Snowflake database, schema, warehouse, and role for the agent to use. The role should already be read-only at the warehouse level as defense in depth.
- A markdown schema description listing the tables and columns the agent is allowed to query, with short notes about what each column means and any join keys.
- Optional default row limit (defaults to 100) and optional max columns to display in a table reply.
Style: thread replies should be concise, use Slack mrkdwn formatting, and always show the SQL that was run.
Additional information
What does this prompt do?
- Listens for @-mentions of the bot in a Slack channel you pick, so anyone on your team can ask a data question in plain English.
- Translates the question into a safe, read-only query against your Snowflake warehouse, grounded in a schema description you provide.
- Replies in the same Slack thread with a clean answer plus the exact SQL it ran, so analysts can sanity-check the logic.
- Refuses anything that isn't a read-only SELECT, and asks a clarifying question instead of dumping huge result sets.
What do I need to use this?
- A Snowflake account, with a role that has read access to the tables you want to expose.
- A Slack workspace where the bot can be added to the channel you want it to answer in.
- A short description of your schema (which tables and columns matter, and what they mean) that you can paste into the prompt.
How can I customize it?
- Point it at a specific Snowflake database, schema, warehouse, and role so it only sees the data you want.
- Edit the schema description to add or remove tables, rename columns, or add business definitions the agent should use.
- Change which Slack channel it listens in, how it formats large results, or the default row limit before it asks a follow-up.
Frequently asked questions
Will the bot ever change or delete data in Snowflake?
Do my teammates need to know SQL?
What happens if a question returns thousands of rows?
How does the bot know which tables and columns exist?
Can different teams have their own bot with their own data?
Stop being your team's SQL bottleneck.
Connect Snowflake and Slack once, then let anyone on your team ask data questions in plain English and get a trustworthy answer in the thread.