How to Set Up Slack Alerts When Your SQL Data Changes
Set up Slack alerts for SQL data changes. Post query results to a Slack channel on a schedule, only when data changes, or at a threshold, with code or Draxlr.

A Slack alert for SQL data runs a query against your database and posts the result to a Slack channel, either on a schedule, only when the result changes, or when a value crosses a threshold. It turns numbers like daily sign-ups, revenue, or failed payments into messages your team sees where it already works.
As a business owner, you've got a lot on your plate, from juggling a myriad of responsibilities to making tough calls left and right. But what's the point of making decisions based on events that happened a week ago? It's like trying to drive forward while looking in the rearview mirror. You can't be glued to your dashboards all day, so Slack notifications bring the important changes to you.
The Value of Timely Business Updates through Slack Alerts
- Data at your fingertips: With Slack alerts, crucial business metrics like the daily install count show up in a channel you already read. You stay informed about the data that influences your decisions without opening a single report.
- Recognise anomalies: Suppose you typically receive a certain number of sign-ups per day, and suddenly that number drops by half. A drop like that often points to a broken sign-up flow, and a timely Slack notification lets you fix it before the situation worsens.
- Power your decision-making with timely insights: Alerts can show you how customers behave as it happens. For instance, if most of your paying customers use one specific feature, it might be worth offering that feature to free users as well. Without timely alerts, these signals are easy to miss.
- Keep the team motivated: When team members can see milestone alerts in Slack, they know the progress being made, which can inspire them to push toward the next goal.
- Track progress in real time: Tracking feature usage through alerts surfaces wins that might otherwise go unnoticed. Celebrating them with your team boosts morale and helps you decide where to focus next.
Alerts also protect you from the bad surprises. If someone floods your store with fake orders at 7 PM on a Sunday while you're at the movies, a Slack alert on the order count tells you within minutes, not on Monday morning. For a broader look at monitoring options, see our guide to alerts for SQL data.
What Can Trigger a Slack Alert?
Most SQL alerting setups, whether you code them or use a tool, come down to four kinds of trigger:
- Data changes: the alert fires whenever the query result changes, for example when the total user count goes up or down.
- Specific time: the alert posts the query result at a fixed time on the weekdays you choose, which works well as a daily or weekly report.
- Periodic interval: the alert runs every 15 minutes, 30 minutes, hour, or another interval you pick, for metrics that change through the day.
- Threshold: the alert fires when a value reaches a checkpoint, for example when orders cross 10,000 in a day or when stock for a best-seller hits zero.
In the next two sections, I'll show you two ways to set these alerts up. The first involves writing code; the second uses Draxlr and takes a few clicks.
How to set up a Slack alert via code?
Suppose you want to keep track of the daily sign-ups for your app and only receive Slack notifications when the total number of users changes.
Let's see some examples of how to achieve this in different frameworks. You will need a Slack Webhook URL; you can follow this guide to generate one.
Ruby on Rails
In Ruby, you can accomplish this by using a gem called slack-notifier. This gem provides an easy-to-use wrapper for posting messages to Slack channels.
Steps to follow
- Add slack-notifier to your Gemfile and run
bundle install. - Add a callback to the user model when the user is created or destroyed.
# Gemfile
gem "slack-notifier"
# app/models/user.rb
...
after_create :send_slack_notification
after_destroy :send_slack_notification
def send_slack_notification
Slack::Notifier.new(slack_webhook_url).ping("User count changed to #{User.count}")
end
...
ExpressJS with Mongoose (NodeJS)
You can accomplish this by using a package called slack-notify.
Steps to follow
- Add slack-notify to your package.json and run
npm install. - Add a method to the user model and call it when the user is created or destroyed.
// User.js
...
import SlackNotify from 'slack-notify';
const SLACK_WEBHOOK_URL = '<PASTE YOUR WEBHOOK URL HERE>';
const slack = SlackNotify(SLACK_WEBHOOK_URL);
const userSchema = new mongoose.Schema({
// fields
})
// user.sendUserCountNotification()
userSchema.methods.sendUserCountNotification = async function () {
const userCount = await User.countDocuments()
await slack.send(`User count changed to ${userCount}`)
}
...
Django
You can accomplish this by using a package called slack-sdk.
Steps to follow
- Add slack_sdk to your project requirements using
pip install slack_sdk. - Add a signal listener for user object creation or deletion.
# <app_name>/signals.py
from django.dispatch import receiver
from django.db.models.signals import post_save, post_delete
from slack_sdk.web.client import WebClient
from userman.models import User
client = WebClient("<your_access_token>")
@receiver(post_save, sender=User, dispatch_uid="handle_user_create_signal")
def handle_user_create(sender, instance, **kwargs):
notify_user_count_slack()
@receiver(post_delete, sender=User, dispatch_uid="handle_user_delete_signal")
def handle_user_delete(sender, instance, **kwargs):
notify_user_count_slack()
def notify_user_count_slack():
user_count = User.objects.count()
message = f"User count changed to {user_count}"
client.chat_postMessage(channel="<channel_name>", text=message)
These snippets cover the data-change trigger for one model. Schedules, thresholds, and alerts on metrics that span several tables each need more code, plus a job runner to execute them, and every new alert means another deploy.
How to set up Slack alerts in Draxlr
With Draxlr's Slack integration, you pick a saved query, choose a channel, and set the rule. Draxlr runs the query against your database and posts the result for you.
- Connect Slack. Connect your Draxlr account with your Slack workspace by going to Settings > Organization Settings.
-
Create and save the query you want to watch. Build it with the no-code query builder, generate it from a plain-English question with AI, or write it yourself in the SQL editor. For the sign-up example above, that's a simple count of users. If you'd like to chart the result first, see our guide to SQL data visualization.
-
Open Integrations and click Create Slack Alert. You'll find it under "Integrations" in the navigation bar.
-
Choose the Slack channel. Enter the channel where the notifications should appear and send a test notification to confirm it works. For a private channel, invite Draxlr first by mentioning @Draxlr in that channel.
-
Name the alert, pick the query, and set the schedule. Select the saved query, then choose a specific time (an hour, a minute, and the weekdays) or a periodic interval such as every hour.
-
Decide when the alert should fire. Turn on Data changes to post only when the query result changes. Under it you can optionally set a threshold value, a relative change in percentage, or a specific value, so the alert fires only when the number crosses the line you care about.
-
Save the alert. Draxlr now posts a snapshot of the result (a graph, a table, or a computed value) to your channel whenever the conditions are met.
The same saved query can also notify people by email. Our guide to SQL email alerts walks through that setup.
Tips for Slack Alerts Your Team Will Actually Read
- Name alerts after the decision, not the table. "Enterprise sign-up" tells the channel what happened; "users_count_v2" does not.
- Match the trigger to the metric. Use periodic alerts for numbers that move through the day, specific-time alerts for daily or weekly reports, and data-change or threshold alerts for events that need action.
- Send each alert to the team that acts on it. Payment failures belong in the finance channel and low-stock alerts in the operations channel, not all in one busy #general.
- Cut the noise. If a channel gets an alert nobody reacts to, raise the threshold or turn on data changes so it only posts when something moves.
Conclusion
Slack alerts keep your team on top of the numbers that matter without anyone refreshing a dashboard. You can wire them up yourself with a webhook and model callbacks, or set them up in Draxlr in a few clicks with schedules, data-change triggers, and thresholds included. Connect your database to Draxlr and set up your first Slack alert today.
FAQs
How do I get a Slack notification when my SQL data changes?
Save a query that returns the number you care about, then create a Slack alert on it with the data-change trigger turned on. A tool like Draxlr runs the query on your schedule and posts to the channel only when the result changes. In code, you'd send a webhook message from a model callback or database trigger.
Can I send SQL alerts to a private Slack channel?
Yes. In Draxlr, invite the bot to the private channel first by mentioning @Draxlr there, then enter the channel name when you create the alert. Sending a test notification confirms that Draxlr can post to the channel before the alert goes live.
Can a Slack alert fire only when a value crosses a threshold?
Yes. With the data-change trigger on, Draxlr lets you set an optional threshold value, a relative change in percentage, or a specific value. The alert then posts only when the query result reaches that point, for example when daily orders pass 10,000 or stock for a product hits zero.
Can I get the same alert by email as well as Slack?
Yes. Draxlr sends alerts to Slack and email from the same saved queries, so the finance team can get an email while the operations channel gets the Slack message. Each alert has its own recipients, schedule, and trigger conditions.
Do I need to write code to set up Slack alerts on my database?
No. Writing code works for a single event, like a user being created, but schedules, thresholds, and cross-table metrics each need extra code and a job runner. Draxlr connects to your SQL database and handles the query, the schedule, and the Slack message without code.
About the author

Ameena is the founder of Draxlr, a modern business intelligence platform focused on making data analysis simpler and faster. She writes about embedded analytics, databases, SQL, dashboards, and building scalable data products for modern teams.
If you have questions about anything in this guide, or want to compare options for your specific stack, you can try Draxlr free, or reach out directly through the Draxlr team.

