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 });
}