Reputation: 1714
I'm writing an appointment scheduling app with angular-meteor. One of the requirements is that a text notification be sent out to the customer who made the appointment. The customer provides a cell number. But basically, all I want to do is send out an email X many minutes before the appointment time. Running off the angular-meteor stack, what might be the best way to do this? All of the appointment information is saved to a mongo db.
Upvotes: 1
Views: 579
Reputation: 53185
You might be interested in Meteor job-collection package (not specific to angular-meteor):
A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
job-collection is a powerful and easy to use job manager designed and built for Meteor.js.
It solves the following problems (and more):
- Schedule jobs to run (and repeat) in the future, persisting across server restarts
- […]
In particular job.after(someTimeBeforeAppointment)
// Server
var myJobs = JobCollection('myJobQueue');
// Start the myJobs queue running
myJobs.startJobServer();
// Create a Job (e.g. in a Meteor method)
var job = new Job(myJobs, 'jobType', jobData);
// Specify when it can run and save it.
job.after(someTimeBeforeAppointment).save();
// Server (or could be a different server!)
// How jobs should be processed.
myJobs.processJobs('jobType', function (job, done) {
var jobData = job.data;
// Do something… could be asynchronous.
job.done(); // or job.fail();
// Call done when work on this job has finished.
done();
});
The pollInterval
can be specified in processJobs
options. Default is every 5 seconds.
Upvotes: 2
Reputation: 3922
Write a node script that sends an email to every customer who has an appointment between X minutes and X+10 minutes from the time of running. Once the email is sent, set a boolean flag on the appointment in mongo so it doesn't get sent twice.
Run a cron that triggers it every 5 minutes.
The overlap should make sure that nothing slips though the cracks, and the flag will prevent multiples from being sent.
Upvotes: 1