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.

null

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).

null

Figure 2. Adding the Condition Node

The Condition node appeared. Now it’s time to add a condition.

null

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).

null

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”.

nullFigure 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).

null

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).

nullFigure 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).

nullFigure 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).

nullFigure 9. Connecting the Steps to the Condition Node

This is what the chatbot looks now.

null

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).

null

Figure 11. Renaming The Step

This is how the renamed steps look on the diagram.

null

Figure 12. The Steps Renamed

Let’s see how it works. Click ''Preview'' (see Figures 13 and 14).

null

Figure 13. The Chatbot in Use

null

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.