All posts

How to Send a Slack Alert Every Time Your Form Gets a Submission

Email alerts get buried, but a Slack ping gets seen. Here is how to trigger a Slack notification on form submission, securely and server-side.

Illustration of a website form submission triggering a Slack notification through a server-side incoming webhook, keeping the webhook URL secret and secure.
Published

A new lead fills your form. An email notification goes out, lands somewhere in an inbox, and sits unread until after lunch. By then the lead has messaged two competitors. That delay is expensive, and it is exactly what a Slack alert fixes: a ping in a channel your team already watches, seen in seconds.

Slack makes this easy with incoming webhooks, but most quick tutorials get one thing dangerously wrong: they wire the webhook into front-end code, where the URL is exposed for anyone to grab and abuse. So this guide does it properly, triggering the Slack alert server-side, after storing the submission.

Two caveats before we start. Slack changes its API, so verify the webhook specifics against the current Slack docs. And throughout, treat the webhook URL as a secret, because that shapes the whole approach.

Why Slack alerts beat email for new leads

Speed decides conversions. Leads engaged within five minutes qualify far better than those reached after 30, per research widely cited from Harvard Business Review. Email is where notifications go to wait. A Slack message lands where your team is already looking, so replies happen in minutes, not hours. It is part of the same fast-response setup we cover in our guide to never missing a customer enquiry.

The tool: Slack incoming webhooks

An incoming webhook is a Slack-provided URL. You send it a POST request with a JSON body, and Slack posts that message into a chosen channel. That is the whole mechanism, and it is what turns a form submission into a channel notification.

The critical rule: do it server-side

Here is the rule that most tutorials break. The webhook URL is a secret. Anyone who has it can post to your Slack channel. If you call the webhook from your React or static front-end code, that URL is visible in the browser to anyone who looks, and it will get abused.

So the call to Slack must happen server-side, from a serverless function or backend, never from the browser. Your form sends the submission to your own function, and that function calls Slack.

ApproachWebhook URL exposed?Safe?
From front-end codeYes, visible in browser✗
From a serverless functionNo, kept as a secret✓
From your backendNo, kept as a secret✓
Where to call the Slack webhook

The flow

The full path looks like this: the form submits to your serverless function or backend, that code stores the submission first, then it calls the Slack webhook to post the alert. Storing first matters, so a Slack outage never loses the lead, which we explain in our guide to storing submissions instead of emailing them. This is the same connect-the-tools pattern from our guide to automating lead management with form integration.

Step by step

Step 1: Create an incoming webhook in Slack

In your Slack workspace, create an app or configure an incoming webhook and choose the channel it posts to. Slack gives you a webhook URL. Check the current Slack docs for the exact steps, as the setup UI changes.

Step 2: Store the webhook URL as a server secret

Put the URL in a server-side environment variable, never in your front-end code or your repository. This is the single most important step for safety.

Step 3: Store the submission first

In your function, save the submission to your store before anything else, so the lead exists regardless of what happens with Slack.

Step 4: POST the message to the webhook

Then send the alert from the server side using fetch (see the fetch docs):

// server-side only, never in the browser
await fetch(process.env.SLACK_WEBHOOK_URL, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    text: `New enquiry from ${name} (${email}): ${message}`,
  }),
});

Step 5: Format the message so it is useful

A wall of text is easy to skim past. Include the key fields clearly, and for richer layout Slack supports Block Kit, which lets you format fields and buttons. A simple structured version:

body: JSON.stringify({
  text: "New website enquiry",
  blocks: [
    { type: "section", text: { type: "mrkdwn", text: `*New enquiry*\n*Name:* ${name}\n*Email:* ${email}\n*Message:* ${message}` } },
  ],
});

Step 6: Handle failures gracefully

If the Slack call fails, do not let it break the submission. The lead is already stored, so log the Slack error and move on, or retry. The alert is a convenience layer on top of the stored record, not the record itself.

What to put in the message

Make the alert something the team can act on at a glance.

IncludeWhy
Name and contactSo someone can reply immediately
The messageContext for a specific response
Which site or formUseful if you run several
Source or campaignHelps prioritise and attribute
TimestampShows how fresh the lead is
What to include in the Slack alert

The no-code option

If you would rather not write a function, an automation tool that connects your form service to Slack can do this without code. You link the form to the automation, map the fields, and it posts to Slack on each submission. It is less flexible than your own function and adds a dependency, but for non-developers it is a quick, safe path, since the webhook stays inside the automation, not in your front end.

Reliability: Slack is an alert, not the record

Worth repeating because it is the most common mistake: never make Slack the only place a lead lands. Slack can go down, a message can be missed, a channel can be archived. Always store the submission first, then alert. That way the Slack ping speeds up your response without ever being a single point of failure.

The bottom line

A Slack notification on form submission turns slow, buried email alerts into instant pings your team actually sees, and faster replies win more leads. Create an incoming webhook, keep its URL as a server-side secret, store each submission first, then post a well-formatted alert from your function, handling failures gracefully. Do it server-side, never from the browser. Verify the Slack specifics against current docs, and if you want it built and wired reliably, that is exactly what our team does.

Want instant Slack alerts on every lead?

We will wire your form to post secure, well-formatted Slack notifications the moment a lead arrives, stored first so nothing is ever lost. Done server-side, done right. Free to scope.

Book a free setup call

Frequently asked questions