Agent Skillsnovuhq/novu › novu-manage-preferences

novu-manage-preferences

GitHub

配置 Novu 通知偏好,管理工作流默认设置和订阅者覆盖选项,支持按渠道(邮件、短信等)启用/禁用及只读控制。

docs/.mintlify/skills/manage-preferences/SKILL.md novuhq/novu

Trigger Scenarios

配置通知渠道偏好 设置订阅者覆盖规则

Install

npx skills add novuhq/novu --skill novu-manage-preferences -g -y
More Options

Non-standard path

npx skills add https://github.com/novuhq/novu/tree/next/docs/.mintlify/skills/manage-preferences -g -y

Use without installing

npx skills use novuhq/novu@novu-manage-preferences

指定 Agent (Claude Code)

npx skills add novuhq/novu --skill novu-manage-preferences -a claude-code -g -y

安装 repo 全部 skill

npx skills add novuhq/novu --all -g -y

预览 repo 内 skill

npx skills add novuhq/novu --list

SKILL.md

Frontmatter
{
    "name": "novu-manage-preferences",
    "inputs": [
        {
            "name": "NOVU_SECRET_KEY",
            "type": "secret",
            "required": true,
            "description": "Server-side API key from https:\/\/dashboard.novu.co\/api-keys. Used by @novu\/api."
        }
    ],
    "description": "Configure notification preferences in Novu at the workflow and subscriber level. Set default channel preferences (email, SMS, push, chat, in-app), mark preferences as read-only or subscriber-editable, and manage subscriber-specific overrides. Use when setting up notification opt-in\/opt-out, configuring per-channel delivery preferences, or building a preferences management UI."
}

Manage Preferences

Novu has a two-level preference system:

  1. Workflow defaults — configured in the dashboard for UI based workflows or via code in framework based workflows, apply to all subscribers.
  2. Subscriber overrides — set by end users, override workflow defaults

Workflow-Level Preferences

Set default preferences when defining a workflow with @novu/framework:

import { workflow } from "@novu/framework";

const alertWorkflow = workflow("system-alert", execute, {
  preferences: {
    all: { enabled: true, readOnly: false },
    channels: {
      email: { enabled: true },
      sms: { enabled: false },
      push: { enabled: true },
      chat: { enabled: false },
      inApp: { enabled: true },
    },
  },
});

Authoring workflows in code? See framework-integration for the full Framework setup, Bridge Endpoint, step controls, and deployment.

Channel Types

Channel Description
email Email notifications
sms SMS text messages
push Mobile/web push notifications
chat Slack, Discord, Teams, etc.
inApp In-app Inbox notifications

Read-Only Preferences

Set readOnly: true to hide a workflow's channels from the Preferences UI — subscribers can't toggle them on or off:

const criticalAlertWorkflow = workflow("critical-alert", execute, {
  preferences: {
    all: { enabled: true, readOnly: true },  // subscriber CANNOT disable
  },
});

readOnly vs critical — pick the right one

These are different mechanisms with different guarantees. See design-workflow/references/severity-and-critical.md for the full matrix.

Flag What it does
preferences.all.readOnly: true UI only. Hides the workflow from the Preferences UI so subscribers can't toggle it.
critical: true (workflow-level) Runtime. Bypasses subscriber preferences, skips digest, runs without delays.

If you need the notification to always be delivered (account suspended, security alert, password reset), set critical: truereadOnly: true alone won't override existing subscriber overrides at runtime.

Optional (Subscriber-Editable) Preferences

const marketingWorkflow = workflow("weekly-newsletter", execute, {
  preferences: {
    all: { enabled: true, readOnly: false },  // subscriber CAN disable
    channels: {
      email: { enabled: true },
      sms: { enabled: false },  // off by default, subscriber can enable
    },
  },
});

Subscriber-Level Preferences

Subscribers can override workflow defaults (unless readOnly: true).

Get Subscriber Preferences

import { Novu } from "@novu/api";

const novu = new Novu({
  secretKey: process.env.NOVU_SECRET_KEY,
});

const preferences = await novu.subscribers.preferences.list({
  subscriberId: "subscriber-123",
});

Update Subscriber Preferences

await novu.subscribers.preferences.update(
  {
    workflowId: "weekly-newsletter",
    channels: {
      email: false,   // opt out of email
      inApp: true,    // keep in-app
    },
  },
  "subscriber-123"
);

Global Preferences

Update preferences across all workflows by omitting workflowId:

await novu.subscribers.preferences.update(
  {
    channels: {
      sms: false,  // disable SMS for all workflows
    },
  },
  "subscriber-123"
);

Preference Resolution Order

When Novu determines whether to deliver a notification:

  1. Subscriber workflow preference (most specific) — subscriber's override for this specific workflow
  2. Subscriber global preference — subscriber's default across all workflows
  3. Workflow default — developer-defined default in code
  4. System default — all channels enabled

The most specific preference wins. If a subscriber disables email for a specific workflow, that takes precedence even if their global email preference is enabled.

Preferences UI Component

React

import { Inbox } from "@novu/react";

function App() {
  return (
    <Inbox
      applicationIdentifier="YOUR_NOVU_APP_ID"
      subscriberId="subscriber-123"
      subscriberHash="HMAC_HASH"
    >
      {/* The Preferences panel is built into the Inbox */}
    </Inbox>
  );
}

The <Inbox /> component includes a built-in Preferences panel accessible via the settings icon.

Standalone Preferences

Use the <Preferences /> component independently:

import { Inbox, Preferences } from "@novu/react";

function PreferencesPage() {
  return (
    <Inbox
      applicationIdentifier="YOUR_NOVU_APP_ID"
      subscriberId="subscriber-123"
    >
      <Preferences />
    </Inbox>
  );
}

Common Patterns

Critical Alerts (Always On)

preferences: {
  all: { enabled: true, readOnly: true },
}

Subscribers cannot opt out. Use for security alerts, payment notifications, legal notices.

Marketing (Opt-Out Friendly)

preferences: {
  all: { enabled: true, readOnly: false },
  channels: {
    email: { enabled: true },
    sms: { enabled: false },
  },
}

Subscribers can toggle channels. SMS is off by default.

In-App Only by Default

preferences: {
  all: { enabled: false },
  channels: {
    inApp: { enabled: true },
  },
}

Only in-app is on. Subscribers can enable other channels if desired.

Common Pitfalls

  1. readOnly: true is per-workflow, not per-channel — you set readOnly on the all level. Individual channels inherit it.
  2. Subscriber overrides don't apply to readOnly workflows — if the workflow is read-only, subscriber preferences are ignored.
  3. enabled: false in the workflow default means the channel is off — subscribers can still enable it (unless readOnly: true).
  4. The Preferences UI only shows non-readOnly workflows — read-only workflows are hidden from the subscriber's preference panel.
  5. Global preferences apply across all non-readOnly workflows — they're a convenient "disable all email" setting, but workflow-specific preferences take precedence.

References

Version History

  • 56a8a16 Current 2026-08-29 05:11

Same Skill Collection

.agents/skills/email-best-practices/SKILL.md
.agents/skills/frontend-design/SKILL.md
.agents/skills/linear-release-setup/SKILL.md
.agents/skills/react-email/SKILL.md
.agents/skills/testerarmy-cli/SKILL.md
.claude/skills/better-auth-best-practices/SKILL.md
.cursor/skills/add-channel-connect-button/SKILL.md
.cursor/skills/add-channel-setup-guide/SKILL.md
.cursor/skills/address-pr-review/SKILL.md
.cursor/skills/better-auth-best-practices/SKILL.md
.cursor/skills/ink-tui/SKILL.md
.cursor/skills/novu-prepare-pr/SKILL.md
.cursor/skills/nv-implement/SKILL.md
.cursor/skills/nv-park-and-review/SKILL.md
.cursor/skills/nv-worktree-cleanup/SKILL.md
.cursor/skills/nv-worktree-commands/SKILL.md
.cursor/skills/nv-worktree-create/SKILL.md
.cursor/skills/run-api-e2e-tests/SKILL.md
.cursor/skills/sanity-changelog/SKILL.md
.cursor/skills/triage-agent-eval-failures/SKILL.md
docs/.mintlify/skills/dashboard-workflows/SKILL.md
docs/.mintlify/skills/manage-subscribers/SKILL.md
docs/.mintlify/skills/trigger-notification/SKILL.md
.agents/skills/figma-use/SKILL.md
.cursor/skills/add-channel-whats-next-onboarding/SKILL.md
.cursor/skills/nv-endpoint-routed-tool-provider/SKILL.md
docs/.mintlify/skills/design-workflow/SKILL.md
docs/.mintlify/skills/framework-integration/SKILL.md
docs/.mintlify/skills/inbox-integration/SKILL.md

Metadata

Files
0
Version
56a8a16
Hash
38edccf4
Indexed
2026-08-29 05:11

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-01 06:52
浙ICP备14020137号-1 $Carte des visiteurs$