© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
NovuN
Novu•13mo ago•
8 replies
Brad

sendgrid templates

export const testWorkflow = workflow(
  "test-workflow",
  async ({ step, payload }) => {
    // First email - Welcome
    await step.email("welcome-email", async () => ({
      subject: `Welcome aboard!, ${payload.userName}`,
      body: "Welcome to our community!",
      customData: {
        templateId: "d-fdb779e07e084227aa3d9cd79e08c8ac", // Welcome template
        dynamicTemplateData: {
          subject: `Welcome aboard!, ${payload.userName}`,
          fullName: payload.userName,
          userName: payload.userName,
          currentDate: new Date().toLocaleDateString(),
          unsubscribe: "https://www.google.com",
          preferences: "https://www.google.com/preferences",
        },
      },
    }));

    // First delay
    await step.delay("delay-1", () => ({
      type: "regular",
      unit: "seconds",
      amount: 15,
    }));

    // Second email - Getting Started
    await step.email("followup-email", async () => ({
      subject: `Let's get started!, ${payload.userName}`,
      body: "Here's steps to get started!",
      customData: {
        templateId: "d-second_template_id", // Replace with your second template ID
        dynamicTemplateData: {
          subject: `Let's get started!, ${payload.userName}`,
          fullName: payload.userName,
          userName: payload.userName,
          currentDate: new Date().toLocaleDateString(),
          unsubscribe: "https://www.google.com",
          preferences: "https://www.google.com/preferences",
        },
      },
    }));

    // Second delay
    await step.delay("delay-2", () => ({
      type: "regular",
      unit: "seconds",
      amount: 15,
    }));

    // Third email - Profile Completion
    await step.email("final-email", async () => ({
      subject: `Time to shine!, ${payload.userName}`,
      body: "Here's how to shine!",
      customData: {
        templateId: "d-third_template_id", // Replace with your third template ID
        dynamicTemplateData: {
          subject: `Time to shine!, ${payload.userName}`,
          fullName: payload.userName,
          userName: payload.userName,
          currentDate: new Date().toLocaleDateString(),
          unsubscribe: "https://www.google.com",
          preferences: "https://www.google.com/preferences",
        },
      },
    }));
  },
  {
    payloadSchema: z.object({
      userName: z.string().default("Boilerplate User Name"),
    }),
  },
);
export const testWorkflow = workflow(
  "test-workflow",
  async ({ step, payload }) => {
    // First email - Welcome
    await step.email("welcome-email", async () => ({
      subject: `Welcome aboard!, ${payload.userName}`,
      body: "Welcome to our community!",
      customData: {
        templateId: "d-fdb779e07e084227aa3d9cd79e08c8ac", // Welcome template
        dynamicTemplateData: {
          subject: `Welcome aboard!, ${payload.userName}`,
          fullName: payload.userName,
          userName: payload.userName,
          currentDate: new Date().toLocaleDateString(),
          unsubscribe: "https://www.google.com",
          preferences: "https://www.google.com/preferences",
        },
      },
    }));

    // First delay
    await step.delay("delay-1", () => ({
      type: "regular",
      unit: "seconds",
      amount: 15,
    }));

    // Second email - Getting Started
    await step.email("followup-email", async () => ({
      subject: `Let's get started!, ${payload.userName}`,
      body: "Here's steps to get started!",
      customData: {
        templateId: "d-second_template_id", // Replace with your second template ID
        dynamicTemplateData: {
          subject: `Let's get started!, ${payload.userName}`,
          fullName: payload.userName,
          userName: payload.userName,
          currentDate: new Date().toLocaleDateString(),
          unsubscribe: "https://www.google.com",
          preferences: "https://www.google.com/preferences",
        },
      },
    }));

    // Second delay
    await step.delay("delay-2", () => ({
      type: "regular",
      unit: "seconds",
      amount: 15,
    }));

    // Third email - Profile Completion
    await step.email("final-email", async () => ({
      subject: `Time to shine!, ${payload.userName}`,
      body: "Here's how to shine!",
      customData: {
        templateId: "d-third_template_id", // Replace with your third template ID
        dynamicTemplateData: {
          subject: `Time to shine!, ${payload.userName}`,
          fullName: payload.userName,
          userName: payload.userName,
          currentDate: new Date().toLocaleDateString(),
          unsubscribe: "https://www.google.com",
          preferences: "https://www.google.com/preferences",
        },
      },
    }));
  },
  {
    payloadSchema: z.object({
      userName: z.string().default("Boilerplate User Name"),
    }),
  },
);


this does not work, if this is triggered it won't use the templateId at all
Novu banner
NovuJoin
Open Source Notification Infrastructure Community by Novu
4,169Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

sendgrid email issue
NovuNNovu / 💬│support
4y ago
Sendgrid Integration with Novu
NovuNNovu / 💬│support
17mo ago
SendGrid overrides not working
NovuNNovu / 💬│support
3y ago
webhook url for sendgrid
NovuNNovu / 💬│support
3y ago