Novu changelog
Type-safe triggers using the Framework SDK
You can now reference a created workflow using the Framework SDK, and get a complete end-to-end type safety and auto-completion for your triggers.
import { workflow } from '@novu/framework';
const commentWorkflow = workflow('comment-on-post', async ({ step }) => {
await step.email();
}, {
payloadSchema: z.object({
post: z.object({
id: z.number(),
title: z.string()
})
})
});
// complete type-safety for the payload object
commentWorkflow.trigger({
to: { subscriberId: '[email protected]' },
payload: {
post: {
id: 1234,
title: 'Post Title'
}
});
It's still possible to make the trigger from any of our backend SDKs (Node, PHP, Go, etc..) following the trigger command:
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).trigger(
name="<WORKFLOW_TRIGGER_IDENTIFIER>", # This is the Workflow ID
recipients="<UNIQUE_SUBSCRIBER_IDENTIFIER>",
payload={}, # Your custom Novu payload goes here
)