Workflow error messages to slack


I looked in to the documentation but the information is very limited or I just don't understand it :slight_smile: End results I am looking for is when the workflow fails I get a slack message.

I created a global error handler with the example from the documentation, I get the error

"error": "sendMessage is not defined"

and how do I push this message through slack when it's working?

Hi Sander,

I usually use same template across all my workflows to track errors.

All you need to do is turn Slack block into Error Handler and pass the message within it by using {{workflowContext.currentRun.error.toString()}}.

You will end up getting a message like this.

If you need a success message you can create another block with a different success template.

Hope that helps!

1 Like

Thanks a lot for the quick reply and suggestions, going to test it now :slight_smile: great stuff

This worked great :slight_smile: thanks a lot

Glad I could help :slight_smile:

Would like to add my thanks to Stefan as this has helped me out also.

Whilst the error was useful, I had quite a large function and the error message was still a little ambiguous as to where the actual problem lied.

So for those that experience the same, within the script that's erroring, you can also just attach whatever you need to the workflowContext, e.g.
workflowContext.currentRun.errorObj = JSON.stringify(x);

Then in your Slack error handler just add this to the bottom.