最後活躍 1730299949

knox 已修改 1730299949. 還原成這個修訂版本

1 file changed, 26 insertions

Novu-2.ts(檔案已創建)

@@ -0,0 +1,26 @@
1 + import { workflow, CronExpression } from '@novu/framework';
2 + import { z } from 'zod';
3 + import { render } from '@react-email/render';
4 +
5 + const commentWorkflow = workflow('comment-workflow', async (event) => {
6 + const digest = await event.step.digest('digest-comments', (controls) => ({
7 + cron: controls.schedule
8 + }), { controlSchema: z.object({ schedule: z.nativeEnum(CronExpression) }) });
9 +
10 + await event.step.email('digest-email', async (controls) => ({
11 + subject: controls.subject,
12 + body: render(<WeeklyDigestEmail { ...controls } events = { digest.events } />)
13 + }), {
14 + skip: () => !digest.events.length,
15 + controlSchema: z.object({
16 + subject: z.string().default('Hi {{subscriber.firstName}} - Acme Comments'),
17 + openAiModel: z.enum(['gpt-3.5-turbo', 'gpt-4o']).default('gpt-4o'),
18 + aiPrompt: z.string().default('Produce a concise comment digest'),
19 + })
20 + });
21 + }, { payloadSchema: z.object({ name: z.string(), comment: z.string() }) });
22 +
23 + await commentWorkflow.trigger({
24 + payload: { name: 'John', comment: 'Are you free to give me a call?' },
25 + to: 'jane@acme.com'
26 + });
上一頁 下一頁