Backend Workflow run hourly

Hey all! I have an backend workflow that consult external API and bring me products of Shopify! It’s works well, but, how i can make this backend workflow call without the users click in button. Like run this backend workflow each hour.

Hey,

You can use recursive workflows for this:

Simply start the workflow at the time you want it to run (or schedule it) and then add an hour to the current datetime when scheduling the next cycle.

Okay, I already use the recursive backend workflow to loop and save the products the API brings me. In this case, to call the API again every hour, I just add a new endpoint calling the same backend scheduled for current date/time +1 hour? It seems like it makes sense. By the way, is there any way that whenever I make calls and save to my database I don’t save the items I already have? Use case: As I always want to keep Shopify’s inventory synchronized with the Bubble database I want to make this call every hour to check if the person has added new items to shopify but I wouldn’t like to get the old items, only if they have new items.

Regarding the recursive workflow, yes, exactly. It’s easy to think of them just as loops, but they can be used just as well for regularly scheduled workflows (which I suppose is still technically a loop, albeit a slow one).

Regarding your last question, I don’t know exactly what kind of unique identifier Shopify uses on inventory records, but you can save this identifier to the Bubble record and search for it whenever you add a new one. Keep in mind if there are a lot of records, this could eat up a big chunk of capacity.

Just thinking out loud now, but if you’re checking/syncing the inventory every hour, you might want to look into using webhooks instead. It’ll be more up to date and a lot more capacity friendly. Again I don’t have experience with Shopify personally but I see they have some inventory related webhooks here.

2 Likes

Yes, each product in Shopify has an ID and I save this ID in the database, I believe that whenever I make a query, having to filter the IDs that already exist so as not to save the same ID’s would be very expensive for the server and I would not I want that. I will study more about webhooks, I think it is the best way to keep stocks and orders up to date, I create a webhook and whenever a new product is added it is sent to this webhook and I save it in the database. Thanks for that tip.

Regarding the recursive workflow, I’ll do that but I think it might not be that necessary although it’s a nice skill to have, webhooks can help me well!

Do you have a example of a loop you used to pull api data directly into the backend? I’m having the same issue where I need to use a front end button.