Skip to content

Quick Start

sarmakska edited this page May 3, 2026 · 2 revisions

Quick Start

git clone https://github.com/sarmakska/webhook-to-email.git
cd webhook-to-email
npm install
cp .env.example .env

Edit .env:

RESEND_API_KEY=re_...
NOTIFY_EMAIL=you@yourdomain.com

Run:

npm start

In another terminal, fire a test webhook:

curl -X POST http://localhost:3000/hooks/test \
  -H "Content-Type: application/json" \
  -d '{"hello": "world"}'

Check your inbox. Email titled "Webhook · test" should arrive in 2-3 seconds.

Add a real webhook source

For Stripe:

  1. Stripe Dashboard → Developers → Webhooks → Add endpoint
  2. URL: https://your-domain.com/hooks/stripe
  3. Select events you want
  4. Copy the signing secret, set it as WEBHOOK_SECRET in .env
  5. Optionally drop src/templates/stripe.js for nice formatting (see Per-Source Templates)

For GitHub:

  1. Repo → Settings → Webhooks → Add
  2. URL: https://your-domain.com/hooks/github
  3. Content type: application/json
  4. Secret: your WEBHOOK_SECRET
  5. Event: select what you want

Add Slack fan-out

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

Restart. Now every webhook also goes to Slack.

What you should see

  • Server logs: webhook-to-email listening on :3000
  • On hit: [stripe] delivered: Invoice paid · 99.00 GBP
  • Email arrives within 2-3 seconds
  • Slack message arrives within 1 second
  • 200 returned to the source service

If something breaks

Problem Fix
RESEND_API_KEY and NOTIFY_EMAIL must be set Edit .env
401 on webhook calls Wrong WEBHOOK_SECRET or missing signature
Emails not arriving Check Resend dashboard for bounces, verify sender domain
Slack messages missing Verify the Slack webhook URL is still active
500 from /hooks/... Check server logs, usually a malformed template

Clone this wiki locally