Takazudo Modular Docs

Type to search...

to open search from anywhere

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

ChannelEnv VariableUsed By
Restock notificationsSLACK_RESTOCK_WEBHOOK_URLnotify-signup
Reservation notificationsSLACK_RESERVATION_WEBHOOK_URLreservation

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

  1. Go to Slack API: Your Apps
  2. Create or select your app
  3. Enable “Incoming Webhooks”
  4. Add webhook to the target channel
  5. 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

ChannelEnv VariableUsed By
Stock notificationsDISCORD_WEBHOOK_URLnotify-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

  1. Open Discord Server Settings > Integrations > Webhooks
  2. Create a new webhook for the target channel
  3. Copy the webhook URL and set the DISCORD_WEBHOOK_URL environment variable

Environment Variables

VariableRequiredDescription
SLACK_RESTOCK_WEBHOOK_URLNoSlack webhook for restock channel
SLACK_RESERVATION_WEBHOOK_URLNoSlack webhook for reservation channel
DISCORD_WEBHOOK_URLNoDiscord 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.error but 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

FilePurpose
netlify/functions/shared/webhook.tsShared postWebhook() utility (fetch + error handling)
netlify/functions/shared/slack.tsSlack message formatting and sending
netlify/functions/shared/discord.tsDiscord message formatting and sending

Notification Matrix

EventSlackDiscordAuto-reply Email
Notify signupRestock channel (full details)Stock channel (product only)Confirmation to user
ReservationReservation channel (full details)Not sent (privacy)Confirmation to user