Webhook Notifications (Slack / Discord)
Webhook Notifications (Slack / Discord)
External webhook notifications are sent when users submit “Notify Me” or “Reservation” forms. These run in parallel with the main response and never block or fail the user-facing API.
Architecture
graph LR
U[User submits form] --> F[Netlify Function]
F --> B[Save to Blobs]
F --> S[Slack Webhook]
F --> D[Discord Webhook]
F --> E[Auto-reply Email]
F --> R[Return success to user]
All notifications (Slack, Discord, email) are sent via Promise.allSettled() to ensure every notification attempt completes before the serverless function exits, while preventing any single failure from affecting others.
Slack
Purpose
Private admin notifications for shop management. Includes full customer details (email, name, timestamps) since these go to private Slack channels.
Channels
| Channel | Env Variable | Used By |
|---|---|---|
| Restock notifications | SLACK_RESTOCK_WEBHOOK_URL | notify-signup |
| Reservation notifications | SLACK_RESERVATION_WEBHOOK_URL | reservation |
Message Format
Restock Notification (notify-signup)
:bell: *入荷通知リクエスト*
商品: *OXI One MK2*
メールアドレス: user@example.com
登録日時: 2025/01/15 14:30
https://takazudomodular.com/products/oxi-one-mk2/
Reservation Notification
:memo: *予約リクエスト*
商品: *OXI One MK2*
お名前: 山田太郎
メールアドレス: user@example.com
予約日時: 2025/01/15 14:30
予約ID: res_1706889600000-a1b2c3
https://takazudomodular.com/products/oxi-one-mk2/
:::tip OGP Card Unfurling Product URLs are placed as bare text (not Slack markdown links) so Slack auto-unfurls them into OGP preview cards showing the product image and description. :::
Setup
- Go to Slack API: Your Apps
- Create or select your app
- Enable “Incoming Webhooks”
- Add webhook to the target channel
- Copy the webhook URL and set the corresponding environment variable
Discord
Purpose
Public-facing notifications visible to customers in a Discord channel. Customers can see which products are trending based on restock request activity.
:::warning Privacy Discord notifications only include the product name and URL. No personal information (email, name) is ever sent to Discord since the channel is public. :::
Channel
| Channel | Env Variable | Used By |
|---|---|---|
| Stock notifications | DISCORD_WEBHOOK_URL | notify-signup only |
Reservations are not sent to Discord because they contain private customer information (name, email).
Message Format
:bell: 入荷通知リクエストがありました!
商品: **OXI One MK2**
https://takazudomodular.com/products/oxi-one-mk2/
:::tip OGP Card Unfurling Same as Slack — bare URLs are used so Discord auto-expands them into rich embed cards. :::
Setup
- Open Discord Server Settings > Integrations > Webhooks
- Create a new webhook for the target channel
- Copy the webhook URL and set the
DISCORD_WEBHOOK_URLenvironment variable
Environment Variables
| Variable | Required | Description |
|---|---|---|
SLACK_RESTOCK_WEBHOOK_URL | No | Slack webhook for restock channel |
SLACK_RESERVATION_WEBHOOK_URL | No | Slack webhook for reservation channel |
DISCORD_WEBHOOK_URL | No | Discord webhook for stock notification channel |
All webhook URLs are optional. If a URL is not set, the corresponding notification is silently skipped with an info log.
Context-Specific Values
Different webhook URLs can be configured per Netlify deploy context (production, deploy-preview, branch-deploy) to separate test notifications from production ones:
# Production
netlify env:set SLACK_RESTOCK_WEBHOOK_URL "https://hooks.slack.com/..." --context production
# Deploy previews (point to test channel)
netlify env:set SLACK_RESTOCK_WEBHOOK_URL "https://hooks.slack.com/..." --context deploy-preview
Error Handling
- Webhook failures are logged via
console.errorbut never thrown - Each notification runs independently — a Slack failure doesn’t prevent Discord or email
- The user always receives a success response regardless of notification outcomes
- The shared
postWebhook()utility handles both network errors and non-OK HTTP responses
Source Files
| File | Purpose |
|---|---|
netlify/functions/shared/webhook.ts | Shared postWebhook() utility (fetch + error handling) |
netlify/functions/shared/slack.ts | Slack message formatting and sending |
netlify/functions/shared/discord.ts | Discord message formatting and sending |
Notification Matrix
| Event | Slack | Discord | Auto-reply Email |
|---|---|---|---|
| Notify signup | Restock channel (full details) | Stock channel (product only) | Confirmation to user |
| Reservation | Reservation channel (full details) | Not sent (privacy) | Confirmation to user |
Related
- POST /api/notify-signup - Notify Me form endpoint
- POST /api/reservation - Reservation form endpoint
- Email Service - Resend email configuration