Send Slack notifications from your app
Slack alerts are only useful if people keep reading them. Here is how to wire them up so the channel stays signal, not noise.

Key takeaways
- An incoming webhook posts to one channel and needs no code on Slack’s side beyond a small Slack app. A bot token is for posting to many channels or threading replies.
- Both the webhook URL and the bot token are secrets: store them in Backend → Secrets and post only from edge functions.
- Route by urgency: instant alerts for things a person must act on, a morning digest for everything else. Buttons that change data need Slack signature checks.
To send Slack notifications from your app, create a Slack app in your workspace, turn on Incoming Webhooks, add a webhook for the channel you want, and store the URL as a backend secret. A server function then POSTs a JSON message to that URL when an event happens: a new customer, a failed payment, a support request. That is enough for most teams. Use a bot token instead when you need to post to many channels, reply in threads or update a message later.
What you'll build
The example is a small subscription product run by three people. They want to know, in Slack, about the moments that need a human, and nothing else:
- #sales, instantly: a new paid subscription, with plan, monthly amount and company name.
- #support, instantly: a support form submission, with a link to the conversation in the admin panel.
- #alerts, instantly: a payment that failed after retries, or edge function errors above a threshold.
- #daily, at 9:00 local time: one digest with yesterday's signups, cancellations, MRR change and open support count.
What you need
- 01Permission to install apps in your Slack workspace (some company workspaces require admin approval).
- 02A Slack app created from Slack's app dashboard, with Incoming Webhooks switched on and one webhook per channel. Each URL starts with `https://hooks.slack.com/services/`.
- 03The URLs in [Backend → Secrets](https://docs.startbase.ai/cloud/cloud-secrets): `SLACK_WEBHOOK_SALES`, `SLACK_WEBHOOK_SUPPORT`, `SLACK_WEBHOOK_ALERTS`, `SLACK_WEBHOOK_DAILY`.
- 04Optional: a bot token (it starts with `xoxb-`) with the `chat:write` scope if you want threads or message updates, stored as `SLACK_BOT_TOKEN`, and the bot invited to each channel.
Route events, do not just forward them
The difference between a Slack integration people love and one they mute is routing. Keep the rules in one table so changing them is a data edit, not a code change:
- `subscription.created` → sales, instant
- `support.created` → support, instant
- `payment.failed_final` → alerts, instant
- `function.errors_spike` → alerts, instant, at most once per 30 minutes
- `user.signed_up` → daily digest only
- `subscription.canceled` → daily digest, plus sales instantly if the plan was over $200 a month
Your app writes events to a `notifications` table as they happen. A `notify-slack` function picks up instant ones, looks up the route, formats the message and posts it, then marks the row sent. A scheduled job builds the digest at 9:00 from the rows marked digest-only. Jobs run on cron schedules in UTC, so convert your team's 9:00 to UTC and remember that daylight saving moves it.
Messages built with Block Kit
A plain `text` field works, but Block Kit messages are easier to scan. A new subscription message might use a header block (New subscription: Pro), a section with two fields (Company: Northwind Studio, MRR: +$49), a context line (Signed up 12 days ago, 3 projects) and a button that links to the customer in your admin panel. Always include a short top-level `text` too: it is what shows in push notifications and screen readers.
Paste-ready brief
Add Slack notifications for my team. Webhook URLs are in Secrets as SLACK_WEBHOOK_SALES, SLACK_WEBHOOK_SUPPORT, SLACK_WEBHOOK_ALERTS and SLACK_WEBHOOK_DAILY. Create a notifications table (event type, payload, route, status, sent_at) and a slack_routes table I can edit from the admin panel. Write an edge function notify-slack that sends instant events with Block Kit messages: header, two fields, a context line and a link button to the record in the admin panel, plus plain fallback text. Never include customer emails or card details in messages. Throttle error-spike alerts to one per 30 minutes. Add a job that posts a daily digest at 9:00 New York time with signups, cancellations, MRR change and open support tickets. On a 429 from Slack, wait and retry; on any other failure, mark the row failed and show it in the admin panel.
Threads keep a story in one place
With a bot token you can post a message, keep the `ts` value Slack returns, and later reply in its thread. That turns a noisy series into one tidy conversation. A support request posts to #support; when the customer replies, the follow-up lands in the same thread; when an agent closes the ticket, a final 'Resolved by Sam in 2h 14m' reply goes there too. Store the channel id and `ts` on the support row. Incoming webhooks cannot thread, which is the main reason to move to a bot token once the basics work.
Test everything in a private `#alerts-test` channel first with its own webhook, so a formatting bug or a loop spams you and not the team. Switching to the real channels is then a change of secrets, not code.
Pitfalls
- Secrets in client code. A Slack webhook URL lets anyone post to that channel as your app; a bot token can do more. Neither belongs in the browser or a public repo. If one leaks, revoke it in the Slack app settings and make a new one.
- Rate limits. Slack allows roughly one message per second per incoming webhook, with short bursts tolerated. Normal event volume never hits that; a backfill or a bug that loops will. Queue messages and respect `429` responses and their `Retry-After` header.
- Unsigned interactive requests. If you add action buttons or slash commands, Slack calls a public URL on your backend. Verify every request with your app's signing secret (an HMAC of the timestamp and raw body, compared to the `X-Slack-Signature` header), reject timestamps older than five minutes, and answer within three seconds, doing slow work afterwards.
- Too much personal data. Slack messages are searchable by the whole workspace and kept per its retention settings. Post a name and a link to your admin panel, not emails, addresses or payment details.
- Alert fatigue. If a channel gets more than a few dozen instant messages a day, people stop reading it. Move events to the digest until each instant alert is something someone acts on.
- Silent failures. A notification that fails to send is invisible by definition. Keep the `failed` rows visible somewhere you look, and check Backend → Logs when Slack goes quiet.
Beyond alerts
Once notifications work, the same pipeline powers a lot: a weekly metrics post built from the metrics that matter, a 'new review' message for each piece of user feedback, or a summary of yesterday's signups written by an AI feature in your app. Keep the routing table as the single place that decides what goes where, and the channel stays useful as the product grows.
Frequently asked questions
Should I use a Slack incoming webhook or a bot token?
Use an incoming webhook to post to a fixed channel; it is simpler. Use a bot token with chat:write when you need many channels, threaded replies or editing a message after posting.
Can I send Slack messages from frontend JavaScript?
You should not. The webhook URL or token would be visible to every visitor. Post from an edge function that reads the secret from Backend → Secrets.
How do I add buttons that do something in my app?
Give your Slack app an interactivity request URL pointing at a public edge function, verify each request with the signing secret, respond within three seconds and do the work after. Link buttons that only open a page need none of this.
How many Slack messages can my app send?
About one per second per incoming webhook, with short bursts allowed. If you hit 429 responses, queue messages, honor Retry-After and move low-priority events to a digest.

