Branch
The Branch
node allows you to create conditional paths in your Canvas flow. It evaluates conditions and directs the flow to different paths based on the result.
Branch node properties are divided into three tabs: Selection
, Branches
, and Variables
Selection
This is where you define the conditions for branching.
You can choose from five methods to determine the path:
- Button: Present users with clickable options to choose their path.
- AI: Let AI analyze the user input and determine the appropriate path.
- Button + AI: Let AI analyze the user input and determine the appropriate path. If AI cannot find a match, it will show the buttons.
- Contains: Check if the user input contains specific phrase.
- Regex: Use regular expressions to match patterns in user input.
You can find the detailed explanation of each method below
Button
This method shows buttons to the user to choose the path. When the user clicks on a button, the flow will continue on the path that corresponds to the button.
When you select the Button method, you can define the button options in the Branches
tab and connect them to the desired paths.
When you select the Button method, you can display a message to the user before showing the buttons in the Selection
tab. This message can help guide the user in making a choice.
AI
This method uses AI to analyze the user input and determine the path. AI will try to match the user input with the defined branches and select the appropriate path. The AI method is useful when you want to handle a wide range of user inputs and provide a more flexible branching logic.
Here is a sample of the AI method in action:
When you select the AI method, you can display a message to the user when the AI cannot find a match in the Selection
tab. This message can provide a more engaging experience for the user.
If the AI cannot find a match, the flow will drop to the Else
path. You can select the number of retries before dropping to the Else
path in the Selection
tab.
Button + AI
This method combines the Button and AI methods. The AI will analyze the user input and determine the path. If the AI cannot find a match, the flow will show the buttons to the user.
It has the same settings as the AI method, but the branches you define in the Branches
tab will be displayed as button options as well.
This method is useful when you want to provide a more flexible branching logic with the AI method and still give users the option to choose their path with buttons when the AI cannot find a match.
Here is a sample of the Button + AI method in action:
Contains
This method checks if input entered into the Value
field contains the defined phrase. If the input contains the defined phrase, the flow will continue on the path.
This method is useful when you want to match specific keywords or phrases in the user input.
Here is a sample of the Contains method in action:
The Contains method is not case-sensitive but it is sensitive to spaces and punctuation. Make sure to define the phrases correctly in the Branches
tab to match the user input.
Regex
This method uses regular expressions to match patterns in the Value
field. If the input matches the defined regular expression, the flow will continue on the path.
This method is useful when you want to match complex patterns in the user input.
Here is a sample of the Regex method in action:
Regular expressions can be complex and error-prone. Make sure to test your regular expressions thoroughly to ensure accurate matching.
Make sure your regular expressions are compatible with the JavaScript regex engine.
Branches
This is where you define the paths for the conditions you set in the Selection
tab.
The branches you define here will be connected to the Selection
tab based on the method you choose and will have different effects based on the method.
Variables
Here you can rename and decide to keep or discard the output chosen by the branch.
Best Practices
- Choose the appropriate branching method based on your flow's complexity and user interaction needs.
- Craft your conditions carefully to ensure accurate branching.
- Use meaningful labels for your paths to make your flow easier to understand and maintain.
- Test your conditions thoroughly to ensure accurate branching.
- Consider combining multiple Branch nodes for complex decision trees.