N
Novu2mo 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,
},
);
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,
},
);
12 Replies
Pawan Jain
Pawan Jain2mo ago
@electron it should work. Are you facing any issue?
electron
electron2mo ago
yeah the workflow does not seem to be triggered
No description
No description
Pawan Jain
Pawan Jain2mo ago
Check-in activity feed page
electron
electron2mo ago
yeah i did ofcourse. no log
Pawan Jain
Pawan Jain2mo ago
@electron I will debug this. Give me some time
electron
electron2mo ago
sure @Pawan Jain thank you :)
electron
electron2mo ago
also when sending sms am i missing something here? it says Subscriber missing recipient details
No description
Pawan Jain
Pawan Jain2mo ago
is this your code snippet to trigger the workflow? replace recipientPhone with phone
electron
electron2mo ago
i see it's queued now
Novu_Bot
Novu_Bot2mo ago
@electron, you just advanced to level 1!
electron
electron2mo ago
any findings on the initial question? as a work around, i divided email and sms into seperate workflows and trigger it conditionally. But it'd be ideal to have the logic in the same workflow
Want results from more Discord servers?
Add your server