FRE-5335 Hook waitlist signup to send confirmation email via Resend
- Added @shieldai/shared-notifications, bullmq, ioredis deps to API - POST /api/waitlist/signup now sends waitlist_confirmation email via EmailService - Schedules welcome sequence (day1 intro, day3 features, day7 launch teaser) via BullMQ delayed jobs - Added waitlist email worker in @shieldai/jobs to process delayed welcome sequence emails - Templates already in place: waitlist_confirmation, waitlist_intro, waitlist_features, waitlist_launch_teaser with dark-themed HTML layouts Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -134,6 +134,47 @@ export async function scheduleWebhookProcessor() {
|
||||
});
|
||||
}
|
||||
|
||||
// Waitlist email worker
|
||||
import { EmailService } from '@shieldai/shared-notifications';
|
||||
|
||||
const waitlistEmailWorker = new Worker(
|
||||
"waitlist-emails",
|
||||
async (job) => {
|
||||
const { email, name, entryId } = job.data;
|
||||
const templateIdMap: Record<string, string> = {
|
||||
'send-waitlist-intro': 'waitlist_intro',
|
||||
'send-waitlist-features': 'waitlist_features',
|
||||
'send-waitlist-launch-teaser': 'waitlist_launch_teaser',
|
||||
};
|
||||
|
||||
const templateId = templateIdMap[job.name];
|
||||
if (!templateId) {
|
||||
throw new Error(`Unknown waitlist email job: ${job.name}`);
|
||||
}
|
||||
|
||||
const emailService = EmailService.getInstance();
|
||||
const result = await emailService.sendWithTemplate(email, {
|
||||
templateId,
|
||||
variables: { name, entryId },
|
||||
});
|
||||
|
||||
if (result.status === 'failed') {
|
||||
throw new Error(`Failed to send ${templateId} to ${email}: ${result.error}`);
|
||||
}
|
||||
|
||||
return { templateId, email, deliveredAt: result.deliveredAt };
|
||||
},
|
||||
{ connection, concurrency: 5 }
|
||||
);
|
||||
|
||||
waitlistEmailWorker.on("completed", (job) => {
|
||||
console.log(`[WaitlistEmail] Job ${job?.id} (${job?.name}) completed for ${job?.data?.email}`);
|
||||
});
|
||||
|
||||
waitlistEmailWorker.on("failed", (job, err) => {
|
||||
console.error(`[WaitlistEmail] Job ${job?.id} (${job?.name}) failed: ${err.message}`);
|
||||
});
|
||||
|
||||
console.log("Job workers started");
|
||||
|
||||
// Report generation workers
|
||||
|
||||
Reference in New Issue
Block a user