Use daily backend workflow to serve 5 articles to a reusable group

I am creating a single-page news aggregation site. I’d like to randomly choose five articles from my existing article database daily at 8 a.m. PST and serve those to five instances of the reusable element “Article” on my site.

I’m new to Bubble, so I’m not sure I’m thinking about this problem correctly. After reading through the Bubble documentation, I believe I’ve identified a few things I need to build this functionality, but I’m struggling with the logic to work through them. My thinking for this is as follows:

  1. I need a backend workflow that chooses 5 random articles each day at 8 a.m. PST and adds them to my “Daily Article List” data type. Each day, the workflow will clear the Daily Article List and then choose 5 new articles, with a condition set to ensure no duplicate articles arrive in the list.
  2. A second workflow will take the newly created Daily Article List and serve one article on the list to each “Article” reusable element on the page.

If possible, I also plan to use the “article” reusable element to display the top-rated articles in a second tab (filtered by a “Numer of Likes” Article data type). As such, I think I need an outside function (maybe a custom state?) to serve data to the reusable element so that the first tab shows random articles and the second tab shows the “Most Liked” articles.

Am I thinking through this correctly? If so, could someone help / direct me to resources that will help me accomplish this?
Thank you!

Your solution is perfectly fine
Does the article appearing in the second tab need to be updated daily or each time the user refresh the page?
If you need to update the article daily, use an schedule API Workflow
Otherwise, Use “Page is Loaded” event

If you just want any random article, put into repeating data source expressions the :random item operator and then operator items until 5 and you’ll get 5 random articles everytime you open the popup

This is the second tab (I’m still working on the design).

I plan to use the three buttons to filter the articles presented based on the “Number of Likes” each article receives. In the weekly favorites, I hope to display the five most-liked articles served in the past 7 days, monthly in the past 30, and All-Time as the five most-liked articles in the database.

The current “like” functionality updates immediately in the bubble preview (i.e. I press like, and the number of likes displayed on the page immediately increases by 1), so my hope is that these filters will function as a live view of the current most liked articles within each filter.

To do this, I believe I need “served in last 7 days” and served in last 30 days" datatype, both of which are lists of Articles, but I’m unsure how to automatically add articles to these lists once they’re served, and then remove them after 7 or 30 days.

Furthermore, I’m unsure how to pass the results of these lists to the reusable element “Article” on each tab.

I believe this functionality adds quite a bit of complexity, but it’s important as I’m using both weekly and monthly favorites to drive leads to my newsletter.

I used random articles to ensure the reusable element populated correctly, but it’s important to me that the same five articles are served to every user who arrives on the site within a 24 hour period.

Okay, so I’ve solved the display side of the problem. Upon page load, a custom state is created that pulls the most recently created Daily Article List and uses that to populate the five articles that show up on the page.

I am still struggling with the backend workflow. I’m not sure I understand the logic of parameters, passing data from the front into the backend, and how to trigger the workflow.

To clarify, I would like the backend workflow to create a new Daily Article List each day at 8 a.m. PST.

Here is a picture of the workflow as it stands.

In step one, the workflow creates a new Daily Article List. In step two, I’ve tried adding 5 random articles to the list created in step one.
Screenshot 2024-06-24 at 5.55.48 PM

To test this workflow, I am using a button on the main screen to schedule the workflow at the current date time.
Screenshot 2024-06-24 at 5.58.46 PM

When I do this, a new Daily Article List is created, but it only includes one article instead of 5.
Screenshot 2024-06-24 at 5.59.42 PM

Any thoughts on where I’ve messed up?