Schedule API on List Setup

Hi,

I’m interested in setting up a scheduled workflow to run a Stripe API to make transfers to Connect accounts. I’ve reviewed the forums and Bubble Docs, but am still a bit confused on the best way to do this.

I have the outbound API call to Stripe working and I can do these transfers as a button-driven workflow/individually. But if I wanted to ‘batch’ them such that each night all of the transfers are sent over the Stripe API, whats the proper way to do that?

I have a thing called “Transaction” that has all of the details Stripe needs (amount, currency, Connect ID, etc.) that gets created elsewhere. I’m not sure if this is the ideal way to do it, but, based on Bubble docs, I tried setting up a “Recurring Event” > “Schedule API Workflow on a List” backend workflow. but got confused by two pieces: the ‘Scheduled date’ and the design of the API Workflow for it to run. Here is what I have so far:

“Recurring Event” contents:
The ‘search for Transactions’ here contains the criteria for only including the relevant Transactions in the list. I think this is the place to do that?

I’m a little confused on the “scheduled date” above. Does the current setting mean it will run 12 hours after I created this Recurring Event? Or do I need to use the “Set/Cancel a recurring event” action?

Here is the API workflow the Recurring Event runs:
Note the Key of Type Transaction. This is from the Bubble docs, but that part is a little unclear. Is the “list” created in the “Schedule API Workflow” event, then passed one-by-one into “This Transaction”…which is the “transaction’s Payment Amount” (etc.) in the last step/screenshot?

And the actual API call parameters. This is very similar to what a button-driven workflow would use, but, as mentioned above, I’d like to confirm the variables here (“transaction’s Payment Amount”, etc.) are correct/refer to each individual transaction from the list created in the first step.

Am I close? Or is there a better/more efficient way to do this on a scheduled basis?

Thank you in advance.

I think I have it working but will need several days to pass to verify it is properly rescheduling itself each day.

I found this very unintuitive and confusing, but you need 3 distinct pieces:

  1. Create a “API workflow” Backend Workflow
  2. Create a “Recurring Event” Backend Workflow
  3. Create a normal button (on any page) that will eventually trigger the start/end of the scheduling

1) “API workflow” Backend Workflow
This will contain whatever “action” steps you would have if you were triggering the API one item at a time with one change: the “Thing to change” in each step will come from the “Workflow Data Sources” section at the top of the dropdown selector boxes.

You have to set this up in the API Workflow’s options.

When you create the API Workflow, the default should have “Manual definition” selected from the “Parameter definition” dropdown. Below that you can “Add a new parameter”. This just creates the variable your list of Things will get passed to.

Add a “Key” name that meaningful to you (in my case, I used “transaction”) and associate it to the correct “Type” of Thing you are going to tack action on.

For each action you take in this workflow, you want to reference this variable. Ex: “transaction’s Payment Amount” as a value I’m sending to Stripe, where “transaction” is the variable name/Key from above.

2) Once you workflow is done, create a “Recurring Event” Backend Workflow

Use the same “Type of thing” you used for the Key’s Type in the API Workflow (Transaction for me)

This workflow has a single action: “Schedule API Workflow on a list”

Here again, you specify a “Type of thing” (same as before)

Then you define the logic for putting together the actual list that will run through your scheduled actions via the “List to run on” field. I defined a search here the same way I’d do so in cases where I might run this sequence of events on a single Thing.

Set the API workflow to the one you created in step 1.

This should reveal the Key you setup in that workflow (“transaction” for me) with a field where you just select the top entry (which should say something like “This Transaction”.

Set the “Scheduled date” as the current date/time. I’m not sure what changing this actually impacts, as we are going to schedule this to run at a specific day/time in the next step.

3) Create a normal button (on any page) that will eventually trigger the start/end of the scheduling

Now, create a button anywhere in your app that will run a one item workflow.

In the workflow just add the “Set/cancel a recurring event” action.

Select your recurring event from the dropdown.

For “Workflow thing” you can allegedly put anything, as the actual ‘Thing’ your API Workflow will run on is defined elsewhere. However, you have to define something or it won’t work. So I just ‘did a search for’ all Transactions and added “:random item” to the end.

“Frequency” is where you actually set how often your Backend Workflow will run. I selected “Daily”. This is where you can fine-tune the timing (for example, if you only want to run it at 2am, you’d set “current date/time change hours to 2” (or something similar).

NOTE: this is also how you cancel a previously scheduled Backend Workflow. To cancel one, you set the frequency to “None”. So I have two buttons that run nearly identical workflows: one with the frequency set to “daily” and another with it set to “none” so I have the ability to cancel things if there is some sort of issue.

I’ll update this is I learn things aren’t working as expected with this setup.

Hope it helps someone else.