Slack data Q&A bot powered by Snowflake

By General Input

Let your team ask data questions in Slack and get answers from your Snowflake warehouse, with the SQL shown for review.

Integrations

  • Snowflake
  • Slack

Type

Agentic Task

Categories

  • Operations
  • Engineering

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.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredChat quality review board for LiveChat support leadsWin back no-show and cancelled appointments every morningLive Loop returns analytics with product-level drill-downNewsletter pre-flight and approval board for Mailjet sendsTurn a prospect spreadsheet into personalized sequence enrollmentsMailjet email delivery lookup console for support teamsCatch feature flags that never got switched on in productionKajabi customer support console for member access fixes