メール通知
メール通知は Resend API を使用して、登録されたメールアドレスに通知を送信します。
アーキテクチャ
Section titled “アーキテクチャ”メール受信者の登録
Section titled “メール受信者の登録”店舗メール通知先
Section titled “店舗メール通知先”Bell RPC: registerShopEmailRecipient({ shopId, email, name?, registeredBy?, registeredByName?})| フィールド | 説明 |
|---|---|
shopId | 店舗 ID |
email | メールアドレス |
name | 受信者名 |
isActive | 有効/無効 |
categories | カテゴリ設定 (jsonb) |
registeredBy | 登録者 ID |
const response = await fetch('https://api.resend.com/emails', { method: 'POST', headers: { Authorization: `Bearer ${resendApiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ from: 'Speakeasy <notification@plfumg.com>', to: recipient.email, subject: title, html: htmlTemplate, text: plainTextContent })});メールテンプレート
Section titled “メールテンプレート”通知メールは HTML とプレーンテキストの両方で送信されます。
Subject: 【Speakeasy】{title}
{店舗名} からの通知:
{body}
---{url ? リンク: url : ''}受信日時: {YYYY/MM/DD HH:mm} (JST)カテゴリフィルタ
Section titled “カテゴリフィルタ”受信者ごとにカテゴリの有効/無効を設定できます。
Bell RPC: updateShopEmailCategories({ id, categories })直接メール送信
Section titled “直接メール送信”キューを介さず、直接メールを送信する RPC メソッドも提供されています。
Bell RPC: sendEmailRpc({ to, subject, text?, html?})→ { success, error?, messageId? }用途:
- パスワードリセットメール
- テスト通知メール
- システム管理者への通知
顧客へのメール通知
Section titled “顧客へのメール通知”店舗→顧客のメッセージ送信時に、顧客にもメール通知が送信されます。
送信先の決定
Section titled “送信先の決定”contact.userIdから Vault DB のuser.emailを取得contact_pureloversのメール設定を確認- 有効なメールアドレスに送信
メール通知先の管理
Section titled “メール通知先の管理”Bell RPC: removeShopEmailRecipient({ id })Bell RPC: sendShopTestNotification({ shopId, channel: 'email', targetId: recipientId})Counter での表示
Section titled “Counter での表示”メール通知設定セクション
Section titled “メール通知設定セクション”┌──────────────────────────────────┐│ メール通知先 │├──────────────────────────────────┤│ admin@example.com (管理者) ││ カテゴリ: [✓ チャット] [✓ 配信] ││ [テスト送信] [削除] │├──────────────────────────────────┤│ staff@example.com ││ カテゴリ: [✓ チャット] [ 配信] ││ [テスト送信] [削除] │├──────────────────────────────────┤│ メールアドレス: [__________] ││ 名前(任意): [__________] ││ [+ 追加] │└──────────────────────────────────┘- 通知システム 概要 - 全体アーキテクチャ
- 店舗通知設定 - 設定画面
- Bell RPC メソッド - メール関連 RPC