Recursive Workflows

Hey Bubblers,

Does anyone know how to set up recursive workflows in the use case of sending a long list of emails recursively? I know that Bubble mentions recursive workflows on their manual, but they don’t actually tell you how to do it.

You can make a back end api then on your front end schedule the workflow.

The last action in the api workflow can schedule another api workflow or the same api workflow with different data.

Can also do this on lists

Is this what you mean.?

That’s what I thought to, but when building how do I tell Bubble which is the next email it should send to? There isn’t a :next item function or anything

For something like a drip campaign (seems like what you’re doing) of emails I’d do a scheduled api workflow to send/schedule the first email. In your DB have this set with a field for “id” #1 at the end of the flow it would schedule the same api workflow but this time your data sent is “do search for email” with constraints of id = current api workflow “Id” + 1

So then #2 would send.

Then the logic would carry over because once #2 sent the current Id + 1 would = Id #3 so it would work perfect.

1 Like

Yeah I did do that for one of my apps, but I noticed that after 1,000 or so with 5 sec spans it times out or stops running or something

2 Likes

Maybe use the first item to send the first email, then remove the first item, send again to the (new) first item (if not empty), then minus, first, minus, and so on ?

In this post a good advise from Nigel (to avoid infinite loops!) :

Hey,

@cmarchan gave me some tips for doing recursive workflows

Here a few guidelines:

  • Use schedule an api wf (not schedule a wf on a list)
  • Send the list of entries as one of the parameters of the wf (the thing marked as a list)
  • Set up an “index nr” parameter of type number. This will enable you to mark each entry of the list with an index nr (each time +1) when you reschedule the wf on itself (explained below).
  • At the end of wf actions add an action to schedule the wf on itself within an extinguishable condition that forces it to stop in the last entry (otherwise you will run into an infinite loop which can break havoc in your app …). Also, send the index nr parameter +1 so that increments each time.
  • An extinguishable condition could look like this: entry index nr < search things :count
  • Use the “index nr” to condition the actions you need in the wf

Basically it’s the same as doing changes to a list of things, but the difference is that you can taylor changes to each entry in the list :slight_smile: :computer:

5 Likes