Introduction
In this article we will take a good look at the Condition step. It allows to forward a user to a certain action during a chat session depending on their answers. We will build a bot that offers users from Chicago to click a link to a sale .
Let’s incorporate the Condition step into an already existing chatbot that asks the user's name and city.
This is what the existing chatbot looks like.
Figure 1. The Existing Chatbot’s Diagram
Let’s add the Condition node. Drag-and-drop a linking point of the Content node to the canvas. Choose ''Condition'' from the list (see Figure 2).
Figure 2. Adding the Condition Node
The Condition node appeared. Now it’s time to add a condition.
Figure 3. The Condition Node Added
In our case, the condition is living in Chicago. Let’s establish this condition. Click the ''Add Condition'' button and choose ''City'' from the dropdown list (see Figure 4).
Figure 4. Adding a Condition
In the window that appears, enter “Chicago” in the value field (see Figure 5). Uncheck the ''Case Sensitive'' checkbox — it is needed because users can type in lowercase when entering “Chicago”; the operator is “equal”.
Figure 5. Adding a Condition
Now let’s specify steps for cases where the condition is executed and not executed. Add two Content nodes by clicking the ''Add'' button (see Figure 6).
Figure 6. Adding Steps
Let’s fill in the steps on the basis that the user is or is not from Chicago; step two is for users from Chicago. Let’s put the link to a sale in the ''Text'' field in this step (see Figure 7).
Figure 7. Filling in Step two
Step three executes if the user is not from Chicago. Let's assume that in this case the user gets a message that says, ''Have a nice day!'' (see Figure 8).
Figure 8. Filling in Step three
Now it’s time to connect the created Steps two and three to the Condition node. Click on it and choose ''Step two'' and ''Step three'' in the ''Yes'' and ''No'' fields respectively (see Figure 9).
Figure 9. Connecting the Steps to the Condition Node
This is what the chatbot looks now.
Figure 10. The Created Chatbot’s Diagram
You can rename the steps for better usage. Click on the step and hover before or after the hashtag icon. Enter the step name (see Figure 11).
Figure 11. Renaming The Step
This is how the renamed steps look on the diagram.
Figure 12. The Steps Renamed
Let’s see how it works. Click ''Preview'' (see Figures 13 and 14).
Figure 13. The Chatbot in Use
Figure 14. The Chatbot in Use
Conclusion
Now you can use the Condition step and, with its help, build a chatbot performing certain actions depending on conditions.
Leave a comment