Skip to content

Conversation

@Loulou5702
Copy link
Contributor

This new feature allows the scheduler to plan and send newsletters as needed, according to a defined periodicity.

For now, the script executed when sending emails is a simple "hello world" in the console to avoid consuming emails in Postmark. However, you can replace it with the actual newsletter-sending script that we have already developed.

The script checks every 10 seconds if there are newsletters to send. If so, it executes the specified script (currently "hello.ts" for testing purposes).

After sending an email, it schedules the next one based on the user's chosen periodicity.

In this example, we plan to send two newsletters at 19:10.
One person wants another newsletter in 5 minutes, and the other in 6 minutes (this demonstrates different periodicity management).

Example in the terminal :
image

Looking at the database after execution :
image

@@ -0,0 +1 @@
console.log("Hello, World!"); No newline at end of file
Copy link
Collaborator

@jonathanarnault jonathanarnault Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This file does not seem to be useful


// Main
console.log("🟢 Newsletter Scheduler started... Press CTRL + C to stop.");
cron.schedule('* * * * *', checkAndSendNewsletters);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: The cron should be defined on the system.

Or better, can you try to use supabase CRON system ? https://supabase.com/blog/supabase-cron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants