What do you use "custom events" for in backend workflows?

Hi everyone, do you use custom events in backend workflows ?
What for exactly ? They don’t seem useful to me when API workflows can achieve the same things with the additional features of scheduling and looping on a list, but maybe I’m missing something?

Thanks for your insights!
Happy bubbling

1 Like

I suppose there is some process to invoke API workflow, and it’s a bit more complicated than triggering an event. Additionally, you don’t need to care about security context when triggering an event as it’s inherited from invoking workflow. Custom events are preferable when you need to isolate some piece of logic of a complex workflow for maintainability. I didn’t test it, but I also suspect that recursive actions with custom events run faster and cheaper in WU.

1 Like

Thanks Vladimir, I think you’re right that the cost in performance would be lower when triggering an event rather than an api workflow.

Regarding security though, the API workflow will run with the same user who schedule it, and we can easily keep privacy rules enforced as well as not exposing this endpoint publicly, so I’m not sure there is much of a difference in that aspect ?

Agree with you for the logic isolation!

I don’t think we can run custom events recursively though ?

Another point I just thought of, the custom event will execute synchronously withint the workflow that invoked it whereas the scheduled api workflow will run independently on another thread I believe, which could be useful or not based on what needs to happen after the workflow/event is invoked.

1 Like

You can’t trigger custom event from itself, but you can have two events triggering each other mutually.

Agree, that’s also a point.

Ohh that’s an interesting approach, yes!

1 Like

I use backend custom events when i want to pass states in the backend since we can add parameters in custom workflows now.

1 Like

Same way they have the ability on the front end to ensure that a series of actions completes before another action within the series starts…if you have steps 1-3 and then step 4 is trigger custom workflow, and in custom workflow you have 7 actions that need to complete before step 5 from the original series begins, then use custom workflow.

I have in backend API calls that run, that require authentication from User data, which has expiration dates, which need to be refreshed, so I check their expiry, then run custom workflow to get the refresh authentication values, then in original series after the refresh is complete I run the API call.

4 Likes

:+1: This is important aspect we missed :slight_smile: