Recursive Workflows to Send to List of Users

I am completely stuck here.

I have a function where a user can follow a company on my review site. I want the followers of a company to get an email notifying them that a new review has been posted. I have attempted to build a recursive workflow but I cannot figure out where to ID the list

Does anyone know of a good resource? I have not been able to find anything current and end to end.

Not sure what you mean “where to ID the list”?
John

The list that the email alert would get sent to

Hi, you can accomplish this several ways. The key is to have a pre-existing list that can be easily accessed to create the send list. The way you do this can be more or less efficient from a DB(data base) access perspective. Here are the options I could think of… other’s may have better ideas that I welcome.

  1. Create a Follow list field (Follow|Company) in the USER table. Each time they follow add the ID of the company to this list. Then you can do a Search USE where Follow|Company contains Company. This will return a list of user that follow the company of interest. (not the best solution)

  2. Create a Follower list field (Follower List) in the Company table and each time a user follows the company add them to the Follower list. Then you do not have to search the DB since you have the exact list of followers. You can simply use Company->Follower List to point to the list.

The second option is very efficient since you do not have to Search the DB but both 1 & 2 have the 10,000 list element restriction since Bubble only allows up to 10,000 entries in a list field. So a company can only have 10,000 followers.

  1. Create a new thing (table) call Follower with two fields User and Company. Each time a user follows a company add a record to this table with Current User, and Company. This creates a link between the two. Then you can Do Search for Company to retrieve all the Users that have followed to create the list. This is a bit less efficient than option 2 but eliminates the 10,000 record issue mentioned above.

If you want all of this to occur in the backend - create two APIs. The first just gets the list, then second performs the loop. You call the first when a new review has been posted by any user. This first API builds the list - then it calls the second API that performs the loop. You only need to do this if you use option 1 or 3. If you use option 2 then you only need one API (the looper) since you already have the exact list and do not need to build it.

One final though… be very careful since you could be actually sending email after email if reviews are coming fast and furious. I suggest that you create another Company field Eg. Last Review Time. Then, add this to the first API and use it to update the Company Last Review Time to current time. Then you can put a condition on the second API to block it if not enough time has passed since the last review. This would prevent email floods. Or, you could conditionally trigger the second API with a time delay offset so that you never loose the emails but avoid the flood. It would be possible that you might stack up many pending API calls but “so what” the servers would eventually catch up.

Hope this helps, if other’s have better solutions I hope they chime in. I love to learn.
John

2 Likes

That’s it :point_up_2:

THANK YOU! Are there any resources you recommend to really brush up on how to utilize Bubble APIs?