LogoMkSaaS ドキュメント
LogoMkSaaS ドキュメント
ホームページIntroductionCodebaseVideo TutorialsGetting StartedEnvironment Setup
Configuration

Integrations

DatabaseAuthenticationEmailNewsletterStorage
Payment
CreditsCron JobsAIAnalyticsNotificationCaptchaChatboxAffiliates

Customization

MetadataFontsThemesImagesi18nBlogDocsComponentsCustom PagesLanding PageUser ManagementAPI Key Management

Codebase

IDE SetupProject StructureFormatting & LintingUpdating the Codebase
X (Twitter)

Notification

Learn how to set up and use notifications in MkSaaS

MkSaaS supports sending notifications when users successfully complete a payment. This allows your team to receive real-time order alerts in their tools.

Currently Discord and Feishu are supported as notification channels, and it's easy to extend with more notification channels.

Setup

Enable Notification Channel

Configure the notification provider in src/config/website.tsx:

src/config/website.tsx
export const websiteConfig: WebsiteConfig = {
  // ...other config
  notification: {
    enable: true,
    provider: 'discord', // or 'feishu'
  },
  // ...other config
}

Configure Webhook URL

Based on the notification channel you selected, configure the corresponding Webhook URL:

  1. Go to your Discord server and open the channel where you want to receive notifications
  2. Click the gear icon to open Channel Settings
  3. Select Integrations > Webhooks > New Webhook
  4. Set a name and avatar for the webhook (optional)
  5. Copy the Webhook URL and add it to your .env file:
.env
DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."
  1. Go to your Feishu group chat
  2. Click the group name > Group Settings > Bot Management
  3. Add a new Custom Bot and enable Webhooks
  4. Copy the generated Webhook URL and add it to your .env file:
.env
FEISHU_WEBHOOK_URL="https://open.feishu.cn/open-apis/bot/v2/hook/..."

If you are setting up your environment, you can now go back to the Environment Configuration and continue. The rest of this document can be read later.

Environment Setup

Set up environment variables


Notification Message Examples

Discord Message

Discord notifications are sent as messages with green color and structured fields for easy reading.

Discord Message

Feishu Message

Feishu notifications are sent as plain text messages with all purchase information clearly displayed.

Feishu Message

Extending New Notification Channels

MkSaaS supports extending with new notification channels:

  1. Create a new file in the src/notification directory (e.g., slack.ts).
  2. Implement the notification function:
src/notification/slack.ts
export async function sendMessageToSlack(
  sessionId: string,
  customerId: string,
  userName: string,
  amount: number
): Promise<void> {
  try {
    const webhookUrl = process.env.SLACK_WEBHOOK_URL;
    if (!webhookUrl) {
      console.warn('SLACK_WEBHOOK_URL is not set, skipping Slack notification');
      return;
    }

    // Your Slack message implementation
    await fetch(webhookUrl, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        text: `🎉 New Purchase\nUsername: ${userName}\nAmount: $${amount.toFixed(2)}`,
      }),
    });
  } catch (error) {
    console.error('Failed to send Slack notification:', error);
  }
}
  1. Import and call this function in notification.ts:
src/notification/notification.ts
import { sendMessageToSlack } from './slack';

// Add to the sendNotification function
await sendMessageToSlack(sessionId, customerId, userName, amount);

References

  • Discord Webhooks Documentation
  • Feishu Webhook Documentation

Video Tutorial

Next Steps

Email

Configure email services

Authentication

Configure user authentication

Analytics

Configure analytics

Storage

Configure storage

Analytics

Learn how to set up and use various analytics tools in your MkSaaS website

Captcha

Learn how to set up and use captcha in MkSaaS

目次

Setup
Enable Notification Channel
Configure Webhook URL
Notification Message Examples
Discord Message
Feishu Message
Extending New Notification Channels
References
Video Tutorial
Next Steps