NovuN
Novu16mo ago
electron

Workflow: Skip Email for Subscribers Without Email and Try SMS Flow

I am trying to create a workflow where if the subscriber does not have an email we skip the email and try sms flow. But i dont think I am doing it correctly. Additionally I cannot find any resource on this topic.


sample code:

export const rewardSummaryWorkflow = workflow(
  'reward-summary',
  async ({ step, payload, subscriber }) => {
    await step.email(
      'send-email',
      async controls => {
        return {
          subject: `Your Summary`,
          body: renderEmail(controls, payload),
        };
      },
      {
        controlSchema,
        skip: () => !subscriber.email || subscriber.email.length === 0,
      },
    );
    await step.sms('sms', async () => {
      return {
        body: `Yo!`,
      };
    });
  },
  {
    payloadSchema,
  },
);
Was this page helpful?