Temporal workflow state event stream

Hello,

We’re currently using a DIY task runner and looking to replace it with something a little more robust.

One feature that we need to replicate is broadcasting (via a websocket) to users when a workflow execution they’ve queued starts, completes, or fails.

Is there some sort of event stream or callback interface that we could use to be notified when the status of an execution changes?

Thanks

A workflow can execute an activity at the appropriate time that would send the notification.

I can see how I can trigger an activity at the start of a workflow and on completion, how do I trigger one on failure?

You can make it part of the workflow code. If you want to make it generic, implement a custom interceptor that does this.

My understanding as of right now:
We can call a “notifyUsersWorkflowStarted” activity as the first line in our workflow.
We can call a “notifyUsersWorkflowSucceded” activity as the last line in our workflow.

Uncertain:
We can wrap the whole workflow in a try catch block and call a “notifyUsersWorkflowErrored” activity in the catch (and rethrow the exception).

Not possible:
There’s no way to notify the user if a workflow fails due to a worker crashing.

There are interceptors that run on the worker that can intercept the API request telling the temporal server that the state of a workflow has changed, this would cover all bases except a worker crashing.

Am I missing anything?

Cheers,
JB

Uncertain:
We can wrap the whole workflow in a try catch block and call a “notifyUsersWorkflowErrored” activity in the catch (and rethrow the exception).

Yes, you can absolutely put this logic in catch or even in finally block.

Not possible:
There’s no way to notify the user if a workflow fails due to a worker crashing.

This is because workflows don’t fail when workers crash. They just keep running at another worker as if nothing happened . This is the main value proposition of Temporal.