Result Of Backend Workflow & Return Data From API fix

I’ve struggled with this for quite some time since there didn’t seem to be any obvious way to grab the result of a scheduled backend workflow on a page, so thought I’d post the solution here for anybody else that’s struggling with this issue.

The trick here is in using the API Connector to trigger your own workflow, as opposed to using the Schedule API Workflow action:

  • Create backend workflow for whatever your needs are
  • Crucially as the last step in that workflow, add a Return Data From API action, where you define what you want to see on the page (In my case a simple string of comma delimited numbers).
  • Now set up a call in the API connector that triggers your own workflow with a POST (Bubble’s docs cover this process).
  • By referencing the action calling your API, you can see whatever was defined in your Return Data From API action on the page.

12 Likes

Interesting method.

I would suggest also adding error handling to the process since the API call could fail. :grinning:

1 Like

Can definitely be made more robust! That’s 100% a good idea, I just wanted to help put people on the right pathway.

2 Likes

This was not any criticism at all on my part, just a complementary tip. :grinning:

Very interesting method :thinking:

2 Likes

Can only hope it’s marginally as useful as many, many of your posts have been to me :slight_smile:

1 Like

Hi, @ed19

Would you be able to share a bit more detail on this method as I’m also trying to do the same.

Does that mean you don’t invoke the backend workflow with the “Schedule API Workflow” function within the workflow, and instead you invoke the backend workflow using the API Connector?

Thanks,
Simon

Hey Simon,

Yes that’s correct! You call your workflow’s endpoint via the API connector, just like you would use that endpoint to catch a webhook or similar.

Hope that helps!

2 Likes

Thank you so much!

1 Like

This is a great resource!

One note - I think it’s only possible to pass a text string in the API Connector call that triggers the backend workflow with a POST. So for this to work, I believe you need to pass through a unique id of the thing you are trying to pass, then Do search for… in the BE workflow to retrieve the thing. Unless anyone has a different solution for how to pass a thing from FE to BE in this type of example?

Also @Jici I noticed in a few other threads you were telling people returning data from a BE workflow was not entirely possible. So perhaps this solution is something new to consider?

Not sure what you are talking about. Maybe you can point a post?

Glad it’s useful! Was definitely a bit of a eureka moment for me.

Whilst it’s true that you can only pass unique ids from the API connector, you can still set the parameters on your backend workflow to explicit database types. When you make the call, bubble will interpret these correctly as the intended datatypes belonging to the ids sent.

Hope that helps :slightly_smiling_face:

You still can’t return data from a backend workflow, this is just one way of overcoming that missing feature. I use another method that doesn’t use the API connector to get the result of a backend workflow but it still doesn’t make a backend workflow return data.

1 Like

This was exactley what I was looking for! Thanks!
@ed19

1 Like

Glad to help!

1 Like

How secure is this method? You have to expose your endpoint and also move the initial call to the front end. Is the “backend” part of the workflow still completely private?

Since the backend workflow is run server side, only the response is available frontend.

The API key param is private so wouldn’t be displayed, though obviously worth checking for yourself. See here:

Private params are stored server side and appended to calls as opposed to being rendered client side:

2 Likes