Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(framework): Add workflow channel preferences docs #695

Merged
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions sdks/framework/typescript/steps/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,121 @@ type ProviderOverrideOutput = {
```

The `_passthrough` object and the known provider values are deeply merged prior to sending the request to the provider, with the `_passthrough` object taking precedence.


### Workflow Channel Preferences

By default, Novu will show the subscriber preferences in the Inbox component. Subscribers can enable and disable any active channel in the workflow using subscriber preferences.
With Workflow channel preferences, you can control the default preference for a channel and whether a subscriber can change it.

In the channels object, you can specify In-App, SMS, Email, Chat, and Push channel preferences. Each channel takes an object with an optional `enabled` flag that controls whether a notification delivery channel is enabled or disabled by default for subscribers.
The `readOnly` property controls if subscribers can change if a channel is enabled/disabled.

The `readOnly` and `enabled` fields on the `workflow` object are used as fallback values if a channel is not specified explicitly in `channels`.

By default, `enabled` is `true` and `readOnly` is `false` at both the `workflow` and `channels` level.

These preferences can also be controlled from the Novu Dashboard on a workflow. To do so, click on the cog icon at the top right of your screen, and then select the "Preferences" tab.

<Tabs>
<Tab title="In-App Only - Editable">
```typescript
const newWorkflow = workflow(
'only-in-app-channel',
async ({ step }) => {
await step.inApp('send-in-app', () => ({
body: 'Hello there',
}));
},
{
preferences: {
{
workflow: { enabled: false },
channels: {
inApp: { enabled: true },
},
}
},
}
);
```
</Tab>
<Tab title="All Enabled - Editable">
```typescript
const newWorkflow = workflow(
'all-enabled-editable',
async ({ step }) => {
await step.inApp('send-in-app', () => ({
body: 'Hello there',
}));
},
{
preferences: {
{
workflow: { enabled: true },
}
},
}
);
```
</Tab>
<Tab title="All Enabled - Read Only">
```typescript
const newWorkflow = workflow(
'all-enabled-read-only',
async ({ step }) => {
await step.inApp('send-in-app', () => ({
body: 'Hello there',
}));
},
{
preferences: {
{
workflow: { enabled: true, readOnly: true },
}
},
}
);
```
</Tab>
<Tab title="All Disabled - Editable">
```typescript
const newWorkflow = workflow(
'all-disabled-editable',
async ({ step }) => {
await step.inApp('send-in-app', () => ({
body: 'Hello there',
}));
},
{
preferences: {
{
workflow: { enabled: false, readOnly: false },
}
},
}
);
```
</Tab>
<Tab title="In-App Disabled - Editable">
```typescript
const newWorkflow = workflow(
'in-app-disabled-editable',
async ({ step }) => {
await step.inApp('send-in-app', () => ({
body: 'Hello there',
}));
},
{
preferences: {
{
channels: {
inApp: { enabled: false },
},
}
},
}
);
```
</Tab>
</Tabs>