I’m currently working on a project, and there’s a specific aspect where I’ve inquired about users’ preferred email frequency. For instance, if a user chooses to receive emails every 2 weeks, I’m looking for guidance on how to set up a system that will automatically schedule and send emails to users at their chosen frequency. Could you please provide some insights on how to achieve this?
Create an API workflow on your backend that sends the desired email. You can then schedule the API workflow to run in the future by using Current date time + days X
(you can also use change hour to X if you want to schedule it at a particular time of day.
When asking for preferred email frequency, save that preference on the User. It could be a numerical field representing the number of days between emails, or it could even be an Option set.
Once you have the preference, you could simply schedule the API workflow in the future, and in the workflow itself you should add a step that reschedules itself in the future, using the same time delay stated by the user preference.
I would personally use two APIs. I call them the Aggregator and the Looper. The aggregator is a single task scheduled in the future, which triggers a recursive API workflow that loops through all the users with that particular time preference (by doing a search). The aggregator also reschedules itself in the future. The recursive workflow would then loop through the users and send out the email.
This is to avoid having a messy scheduler; instead of having one scheduled task per user, you only have one scheduled task per preference. It also avoids having too many overlapping workflows which might lead to a timeout. Recursive workflows are generally more reliable.
Thank you for your time. I’ll promptly look into this and get back to you with an update at a later time.