Add a node as a fallback to the previous node
In this guide, we'll go through the process of handling node errors using a fallback node. By default, a workflow will fail and stop in case of an error. This is not always a desired behavior and can be adjusted with the fallback fail mode.
In this guide, we will use Cargo's revenue organization feature and handle allocation errors. The failure of an allocation nodes is a helpful feature indicating a lack of capacity in the chosen territory/member. Being able to explicitly detect such cases allow us to handle them with custom logic.
Used Features:
Before you begin
In this guide, we will use existing revenue organization settings and a slack connector. Both are optional as you may want to enable fallback mode on very different nodes.
If you want to implement the same use case, use this guide to set up your revenue organization before.
Add an allocation node
In a blank workflow add a new allocation node. Click the plus icon on the top right of the Cargo workflow editor and find the sales category. Drag the node to the canvas just below the start node.
Link the new node with the previous node of the workflow.
Open the newly added allocation node and specify allocation logic. To illustrate the failure mode we will set a configuration that will cause an error since no member will be available for the allocation.
We can run the node to see the error message.
Right-click the allocation node and pick "failure" from the context menu. Select the fallback option under the fail mode.
This will create a new link handle on the right side of the allocation node. Any node linked from this point onwards will be executed only in case of an error of the allocation node.
In our scenario, we would like to handle any allocation errors by sending a customized slack message to selected members of our workspace.
Click the "add node" icon again and search for slack, drag-and-drop the node to the right side of the allocation node.
Now link the new slack node using the fallback handle on the right side of the allocation node.
If you have not created a slack connector before you can do that now from the node configuration pane.
Customize slack message
Use allocation error message to add details to slack message
Error occurred: {{nodes.allocate.fallbackErrorMessage}}
Now click the slack write node to configure the slack message that will be sent in case of an allocation error.
Select a slack channel which can be a shared channel or a direct message to a user.
It is particularly useful to include the error message in the slack alert since it can contain valuable details of what happened. You can use this in the message content text field:
Finish line
By now, we have successfully set up a fallback mechanism for an allocation node. Now, when an allocation error occurs:
- The workflow will not fail completely.
- Instead, it will trigger the Slack Write node.
- A customized message will be sent to your specified slack channel or users.
This approach allows you to handle errors in a controllable way. Notify the right people, and potentially trigger manual interventions or alternative processes when automated allocation fails.