novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
35.16k stars 3.79k forks source link

πŸš€ Feature: Customized Preference System exposed to bridge #6822

Open paulwer opened 2 hours ago

paulwer commented 2 hours ago

πŸ”– Feature description

With the new version v2 and the introduced bridge processing, novu could also introduce a custom preference system, where devs can define schemas for the preferences like the existing control/payload schema, which are then exposed to the customer and to the workflows as well.

🎀 Why is this feature needed ?

Several different requests like customized digest for workflows are already requested and I think with this system, the chance to support more of them out of the box is even higher. When used with topics (#6789) the dev can define relations between topics and workflows much more specific

Use Cases I could think of:

✌️ How do you aim to achieve this?

  1. Define Preference Schema at workflows / maybe also on topics (#6789)
  2. pass them as variables to the workflow

πŸ”„οΈ Additional Information

Example:

workflow("xxx", async ({ step, subscriber, preferences, topic }) => {
  const { name: topicName, control: topicControl, preferences: topicPreferences } = topic ?? {};;
  await step.digest("custom-digest", () => ({ unit: (topicPreferences?.interval ?? preferences.interval) === 'daily' ? 'day' : 'week', amount: 1 })
}, {
   preferenceSchema: z.object({
      interval: z.enum(["daily", "weekly"]).default("daily"),
   })
})

πŸ‘€ Have you spent some time to check if this feature request has been raised before?

🏒 Have you read the Code of Conduct?

Are you willing to submit PR?

Yes I am willing to submit a PR!

linear[bot] commented 2 hours ago

NV-4564 πŸš€ Feature: Customized Preference System exposed to bridge