Background Task with relative time
I need a background task to RUN "x minutes after an Endpoint fires", right now it seems not possible to setup a variable to when the task runs, am I missing something?
Comments
-
Hi There,
You are correct that a task can not be set to run dynamically, they will only run as per the defined schedule. However, a task can interact with your database, and by using timestamps, boolean columns, etc you can dynamically make your task process a record.
For example, you might want to send a welcome email to a user an hour after they signed up. As part of your signup API function, you could edit a record in your database, and update a signed-up column with a timestamp, and a welcome_email_sent boolean will be set to false.
Then in your task, you can query all user records with a signup time, greater than 1 hour, and a welcome_email_sent with the value "false". You could have this task running as often as every 5 seconds, meaning that within 5 seconds of the hour post their signup elapsing the email would be sent. You would then of course set the bool value of the welcome_email_sent boolean to true, meaning it wouldn't appear in the query results for the next run of the task.
Let me know if this approach wouldn't be suitable for your usecase! -
I do what @Lachlan recommends - leveraging background tasks for delayed actions - regularly. It works well!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback