← Back to Recipes

Slack Integration Guide

Get a Slack message every time someone fills out your form.

1. Create a Slack Incoming Webhook

  1. Go to https://api.slack.com/apps and create a new app.
  2. Under Features, click Incoming Webhooks and enable it.
  3. Click Add New Webhook to Workspace and pick a channel.
  4. Copy the webhook URL — it looks like https://hooks.slack.com/services/T.../B.../...

2. Create a Forwarding Handler

Deploy this as a serverless function (Vercel, Netlify) or a Node.js endpoint. Your frontend posts to this handler, which forwards to Peach Form and then notifies Slack.

// handler.js — deploy to Vercel, Netlify, or any Node.js server
export default async function handler(req, res) {
  if (req.method !== "POST") {
    return res.status(405).end("Method not allowed");
  }

  const body = req.body; // parsed JSON

  // 1. Forward submission to Peach Form
  const pfRes = await fetch("https://api.peachform.com/f/YOUR_FORM_ID", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body),
  });

  if (!pfRes.ok) {
    return res.status(502).json({ error: "Peach Form submission failed" });
  }

  // 2. Notify Slack
  const lines = Object.entries(body)
    .map(([k, v]) => `*${k}*: ${v}`)
    .join("\n");

  await fetch(process.env.SLACK_WEBHOOK_URL, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      text: `New form submission:\n${lines}`,
    }),
  });

  return res.status(200).json({ success: true });
}

3. Set Environment Variables

Add your Slack webhook URL to your deployment environment:

SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T.../B.../...

4. Point Your Frontend at the Handler

Update your form's submit target from the Peach Form endpoint to your handler URL. The handler forwards to Peach Form automatically.

Expected Output

After a successful submission you will see this message in your Slack channel:

New form submission:
*name*: Jane Doe
*email*: [email protected]
*message*: Hello!