Skip to content
Back

App with randomly scheduled notifications + AI challenges - best approach?

  • 0
  • General
  • Flutter
standa 🧃
13 Jul, 2025, 09:53

Hey everyone! �* Building a Flutter app that sends users 1-3 location-based challenges per week based on their preferences.

The flow:

  1. User selects how many challenges/week they want (1-3)
  2. App sends notification during their free time slots
  3. 10 minutes to accept (can refresh once for a different challenge)
  4. If accepted, until midnight to complete
  5. Proximity notification (500-1000m) to remind them to take a memory photo
  6. Photos saved to user's collection

Technical approaches I'm considering:

First

  • Weekly batch job that generates challenges for all active users via AI
  • AI considers user location, preferences, previous trips, local events/weather
  • Store generated challenges in DB with scheduled send times
  • Use Appwrite's scheduled functions to trigger notifications

Second

Schedule random 1-3 times in the free time windows each week. Real-time generation when random time arrives → AI generates 2 challenges → send notification with primary, store secondary for refresh

Third

**On signup: **immediately generate 2 challenges (primary + secondary for refresh) with scheduled function Once user accepts/rejects both challenges → immediately create and prepare another 2 challenges If time runs out: user has to click "prepare new challenge" button → generates new pair but just shows "Wait for the notification for the adventure" screen This avoids inactive users costing $$ for AI calls

My questions:

  • What's the absolute simplest way to architect this? Is it possible and viable to be done with Appwrite? I don't care much about costs, so if it's simpler I could skip batch processing entirely and just generate challenges on-demand when needed. It's just MVP.
  • Simplest way to handle timezones? Convert everything to UTC?
  • Any gotchas I should be aware of?

Since I'm inexperienced and I am learning backend as I go, any architectural guidance or simpler alternatives would be super helpful! Thanks! 🙏

TL;DR
Developers discussing best approach for app with randomly scheduled notifications and AI challenges: consider Appwrite functions to trigger task scheduling and notifications, use Appwrite for databases (users and tasks), messaging for notifications, and storage for saving photos. Run batch jobs at start of week to generate tasks, handle timing of tasks and notifications. Real-time generation before sending notifications recommended for AI considerations.
standa 🧃
13 Jul, 2025, 10:15

App with randomly scheduled notifications + AI challenges - best approach?

standa 🧃
13 Jul, 2025, 10:36

The real-time generation (right before sending the notification) sounds like the most viable, because the AI can take into account events nearby + weather.

Kenny
14 Jul, 2025, 21:20

I think most of this should be accomplishable via Appwrite, you can do the batch job with an Appwrite function (https://appwrite.io/docs/products/functions) run it on a cron for the start of the week or something.

Store user information (like timezone, frequency, location, etc ) in a users collection, and pull from there when generating the tasks. Then a task collection to store the tasks, and information about them. (https://appwrite.io/docs/products/databases)

You can use Appwrite messaging to send out notifications when the task is due, probably another Appwrite function that runs every x number of minutes/hours/days to trigger which tasks are ready be kicked off. (https://appwrite.io/docs/products/messaging)

Things like the 10 min to accept would probably be handled by your frontend by just checking when the task was created against the time the user is trying to accept. Similar with the 24 hour to complete.

You could save photos using Appwrite storage (https://appwrite.io/docs/products/storage)

standa 🧃
14 Jul, 2025, 21:28

Hmm all of this makes sense. So I'd just run something like generateWeeklySchedule(userId) for every user every sunday/monday for example using batch job.

That's understandable, but now that I got 1-3 random times for each user for the upcoming week, how do I make sure I generate the task/challenge in that time and immediately send noti after. Something like generateTaskAndSendNoti(userId). I could use another batch job which runs every 15-30 mins for example and again checks every user/task that is due, but sounds like that's not a good way to handle this to me?

To be honest, I'm really not that experienced with backends etc. - so if batches and backend databases, etc. are built for this, I got no problem doing it this way. Just wonder if it's really the best (yet simple) way.

standa 🧃
14 Jul, 2025, 21:30

Ofc when creating new user I'd have something like generateWeeklyScheduleUntilNextCron(userId) - with way better name 😂 But yeah, those simple edge cases I can handle myself. I just want to be sure I start with decent-ish high-level plan before building.

standa 🧃
14 Jul, 2025, 21:59

if there's no simple solution to this problem, I might just do it the "BeReal" way and just batch create all tasks at once at random time of day and send noti at the same time to all users who should have task generated this day. And I'd do this once per day (per timezone? continent? idk).

standa 🧃
15 Jul, 2025, 13:49

The more I consider this approach, the more convinced I am that this model is the right direction. I'm feeling confident about developing a decent-ish architecture on my own, so thank you for all your guidance - it's been incredibly helpful. When I have the architecture sketched out, would you mind if I run it by you? I'd really value your perspective on potential pitfalls or edge cases I might have missed, given your experience

Kenny
15 Jul, 2025, 13:55

I think I would just have one longer running cron that executes at midnight sunday, this cron generates the tasks for every user. As the platform grows this probably won't work, but for a small MVP, I think it's fine.

standa 🧃
15 Jul, 2025, 13:56

still, something would have to triger notifications at the proper time 🤔

Kenny
15 Jul, 2025, 13:56

I would generate these tasks, off the top of my head I couldn't give you exact code for getting a timestamp for the next week, but I think you could probably do something with math.random and get the epoch time from sunday - saturday and use that to clamp the random epoch time.

standa 🧃
15 Jul, 2025, 13:57

I found out upstash qstash / workflow or Google cloud tasks is exactly for that - executing scheduled events per user, but i'd love to stay in appwrite's ecosystem

standa 🧃
15 Jul, 2025, 13:57

least dependencies possible

Kenny
15 Jul, 2025, 13:57

For notifications I would create a cron that runs every minute and pulls from your collection where task is for that minute and send out emails or notifications then

Kenny
15 Jul, 2025, 13:58

or you could do it a bit ahead and pull for tasks that are the next minute or something, I did something similar in a discord bot I made.

standa 🧃
15 Jul, 2025, 13:58

sounds do-able if i decided not to go with the bereal style of notis

standa 🧃
15 Jul, 2025, 13:59

with the bereal style, i only need 4 crons to generate tasks and send noti's (for each timezone), so its way simpler.

Kenny
15 Jul, 2025, 13:59

I'm not familiar with bereal :P

Kenny
15 Jul, 2025, 13:59

You can create an appwrite function that has the event for new user, when a new user is created the function is triggered that creates the task schedule

standa 🧃
15 Jul, 2025, 14:00

oh there's something like triggers in sql - on user create / new row?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more