Stop Paying for Slack Alerts: Send Sentry Errors to Slack for Free
Source: Dev.to
Tired of paying for Sentry’s Slack integration? Good news: you don’t have to.
With a simple setup using Sentry webhooks, Vercel Edge Functions, and Slack’s free chat.postMessage API, you can receive real‑time error notifications in Slack—without a premium plan.
Why Pay for What You Can Build?
Sentry’s built‑in Slack integration is behind a paywall. For indie developers and small projects, that cost often isn’t justified.
Instead, you can:
- Use Sentry’s webhook integration
- Catch events with a Vercel Edge Function
- Send formatted messages using Slack’s free API
Same result. Zero extra cost.
Step 1: Set Up the Sentry Webhook
- Open your Sentry project settings.
- Go to Legacy Integrations → Webhooks.
- Add a new webhook (you’ll paste your Vercel function URL here after deployment).
Sentry will now send error events to your custom endpoint.
Step 2: Create the Vercel Edge Function
If you’re new to Vercel, it’s a serverless platform that runs code at the edge with a generous free tier.
We’ll create an Edge Function that:
- Receives Sentry events
- Formats them using Slack Block Kit
- Sends them to Slack via the API
export const config = {
runtime: 'edge',
};
const sendMessage = async (
channel,
{ level, formatted, environment, email, title, culprit, project }
) => {
const isError = level === "error";
const blocks = [
{
type: "section",
text: {
type: "mrkdwn",
text: `${isError ? ":red_circle:" : ""} *${title}*`,
},
},
{
type: "section",
fields: [
{ type: "mrkdwn", text: `*Environment:*\n${environment}` },
{ type: "mrkdwn", text: `*Level:*\n${level}` },
{ type: "mrkdwn", text: `*Project:*\n${project}` },
],
},
{
type: "section",
fields: [{ type: "mrkdwn", text: `*User:*\n${email}` }],
},
{ type: "divider" },
{
type: "section",
text: { type: "mrkdwn", text: `*Message:*\n${formatted}` },
},
{
type: "section",
text: { type: "mrkdwn", text: `*Culprit:*\n${culprit}` },
},
{ type: "divider" },
];
await fetch("https://slack.com/api/chat.postMessage", {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
Authorization: `Bearer ${process.env.SLACK_ACCESS_TOKEN}`,
},
body: JSON.stringify({ channel, blocks }),
});
};
export default async (req) => {
const body = await req.json();
const {
project,
culprit,
event: {
level,
logentry: { formatted },
user: { email },
environment,
metadata: { title },
},
} = body;
await sendMessage(process.env.CHANNEL_ID, {
level,
formatted,
environment,
email,
title,
culprit,
project,
});
return new Response("Event received");
};
What This Does
- Receives error events from Sentry.
- Formats a structured Slack message using Block Kit.
- Posts directly to Slack with an OAuth token.
Step 3: Create and Configure Your Slack App
- Go to .
- Create a new app in your workspace.
- Under OAuth & Permissions, add the scope
chat:write. - Install the app to your workspace and copy the OAuth Bot Token.
Add the following environment variables in Vercel:
SLACK_ACCESS_TOKEN– the bot token you just copied.CHANNEL_ID– the ID of the Slack channel that should receive alerts.
Step 4: Deploy to Vercel
- Push the code to GitHub.
- Import the repository into Vercel.
- Add the environment variables (
SLACK_ACCESS_TOKEN,CHANNEL_ID). - Deploy.
After deployment, copy the Edge Function URL and paste it into your Sentry webhook settings.
Step 5: Test It
Trigger a test error in Sentry. If everything is configured correctly, a clean, structured error notification will appear in Slack within seconds.
Why This Setup Wins
- Completely free.
- Real‑time notifications.
- Fully customizable Slack formatting.
- Serverless and low‑maintenance.
- Works on Sentry’s free plan.
Grab the Code & Customize It
Feel free to adapt this setup for your own workflow:
- Add severity filtering.
- Route different projects to different channels.
- Change formatting for staging vs. production.
If this helped you save money or improve your monitoring, consider starring the repository and sharing it with other developers.
Happy building 🚀