No I don't mean to schedule specific functions to run everyday or week or something like that.
What I mean is say after some specific event(user did something) I need to run another function say after 10 days in context of the user which for example - ascertains the actions by user and judges if i should reach out via email or not.
Most of the solutions offer to run some function repeatedly on a schedule(every 10 days). Where as I want each individual function to be able to schedule itself after a certain event + say 10 days.
Is there an existing solution I can use for this? or what other workaround is there for this?
Thanks :)
You need some sort of scheduler / queue. I've personally had good results with inngest (not affiliated), and they're pretty responsive on their Discord too.
It's not so much about scheduling a single action to execute in the future, there's more complexity like error handling, ensuring you're not scheduling the same message multiple times, etc...
Great question, Owl Maniac! 😊 Your need to schedule API calls based on specific user events is quite unique. One solution might be to use a combination of a job scheduler like Celery and a message broker like RabbitMQ. With Celery, you can schedule tasks to run at specific times, and RabbitMQ can handle the event-driven part. Another option could be using AWS Lambda with CloudWatch Events, where you can trigger Lambda functions based on events and set delays. Hope this helps! Good luck!
So, you want the user to do something, then after x amount of time for something to happen in the app (send an email, flash their screen, or trigger some other type of functionality), right?
You can go about this in a few different ways, depending on what your stack is. If you're using a js stack (next, react, vue, whatever) you can use serverless functions (firebase functions are awesome for this), a job queue library like BullMQ or service like AWS SQS, creating a short term timeout hook, or run a cron job.
If you are using rails, you can use ActiveJob, Resque/Sidkiq or similar job queue library, AWS SQS or similar job queue service, or run a cron job.
It just depends on what your stack is and what your requirements are.
I like to ask chatgpt/gemini to help me weigh the pros and cons of architecture decisions like this.
To schedule API calls, you can use a task scheduler like cron for Unix-based systems or Task Scheduler for Windows. Alternatively, you can implement scheduling within your application using libraries such as Celery for Python or node-cron for Node.js. It's important to ensure that your scheduler can handle retries and error logging for robustness. For cloud solutions, services like AWS Lambda and Google Cloud Functions can be used to automate API calls efficiently.
You might find Celery with Redis or RabbitMQ quite useful for scheduling API calls after specific events. It's flexible and allows for delayed task execution, fitting your needs perfectly. Hope this helps!
This is the purpose of a webhook management platform. How this works in your case is:
What's wrong with a cron job?
You're too good for polling?
As parent said - once a day you could check how many days ago user did x. If it’s 10 days ago (and not 9 like yesterday or 11 like tomorrow), fire your event!
Do you have a database (could literally be Google Sheets) to log when the event occurs for each user? If so then you can just have a job running that checks that database every hour and then triggers the action based on if the logged date is > 10 days.
We use that strategy somewhat regularly at Orderly by leveraging Xano
Easiest thing I can think of would be to call out to something like Zapier or Make with the event and context via webhook, then add a delay for the relevant period of time, then have it either do the work inside of the Zap/Scenario or call back to your API to finish the processing.
I dont really know specific platform which suitable your needs, i'm quite sure it's not about cron job... maybe you can search something related to workflow engine
Netflix has open source system called conductor, or maybe you can check apache airflow, AFAIK it has conditional capability
I would say just figure out your "check interval" (/ day, / minute, etc) then schedule a cron task to run every interval.
After that create a database which contains triggered events, with a field for when the event should fire (timestamp in the future).
Then in your cron task, fetch all the outgoing events so to speak. That is - the events which have a "do_at_timestamp" that's now less than the current timestamp (in the past).
All the events returned by that query will then need be to be handled accordingly! 🙂
If you are developing PHP go for cron jobs. If you are using any other language, the queue system is much more handy. Good luck!
You have a couple of options here:
A simple solution here would be to have a chron job set up to run once a day and execute a list of functions that match the current date.
I've used this method several times before evolving into a message queue. What I did was create a table,
events, that stored required information and a timestamp; if the current date matched the date at the time of the chron, it would perform all actions and clear my events table. Simple and straightforward, I used this at well over 100k API requests/dayA more complex system that should scale better but is more hardcore to set up. This could be overkill and a time sync, depending on your current scale.
Your discussions on the importance of user-friendly APIs resonate with me. As I’ve worked to implement those ideas, I found that EchoAPI has really streamlined my design workflow.
Scheduling API calls involves automating the process of sending requests to an API at specified intervals or times. This can be achieved through various methods:
Cron Jobs: On Unix-like systems, cron jobs allow you to schedule tasks, including API calls, to run at specific times or intervals.
Task Scheduler: On Windows systems, Task Scheduler can be used to schedule API calls by creating a task that executes a script or program at designated times.
Third-Party Services: Platforms like Zapier, Integromat, or AWS Lambda provide tools to schedule and automate API calls without direct server access.
Programming Languages: Using languages like Python (with libraries like Celery or APScheduler) or Node.js (with packages like node-cron) allows you to schedule API calls programmatically within your application.
You can schedule API calls using cron jobs in Linux or scheduled tasks in Windows, or by using cloud services like AWS Lambda.
Can AWS Step Function help here?
Hey, you can try creating one-time cronjobs at FastCron (free up to 300 one-time cronjobs).
You need something like temporal.io
It's oss as well.
https://cron-job.org/en/
This is a free tool that allows you to hit a url on your project at whatever interval you need.
The CookOut menu is a delightful homage to classic American fast food, boasting a diverse array of options that cater to all tastes. Known for its premium quality and affordability, CookOut offers an extensive selection of grilled favorites, including juicy burgers, succulent chicken sandwiches, and hearty BBQ plates.