How to create complex flow conditions

Variable and Tag conditional switches are the bread and butter of any basic chatbot flow. Changing the flow based on a reply or on a value is very easy using Xenioo and using nested Operations we are not limited to a single switch.

To create our complex flow condition let’s describe it using simple text first.

if user is VIP
  if more than 8 hours passed since last contact
      Say "Hello Sir! Long time no see!"
  else
      Say "Welcome back sir!"
else
    Say "Hey you."

For the sake of our example, we assume that our users are tagged as VIP (or not). So our first step would be to add a check on the VIP tag using a Tag Switch Action like below:

Notice how some actions have a small flash icon on the bottom right? That icon is highlighting the presence of a trigger: it means that the action we’re looking will run other child actions if the trigger rule is met. On our Tag Switch action, the rule is that the condition is met.

So by using the Add Operation button we add a Variable Switch Action to check for how much time passed since last contact with the current user. Our final panel will look similar to this:

So with this, we’ve basically written the first part of our conditions: if the user is a VIP and if more than 8 hours passed since last contact. Since on this condition we need to display a message, we just add a Go To action and redirect the flow to another message.

Again, notice how there is a small line joining our Variable Switch with the Go To: it wants to underline that the Go To action will not be executed unless the Variable Switch condition is met. Keeping this in mind, we can add another Go To action as a child of our Tag Switch, so that if the user is a VIP but less than 8 passed we can display another message.

With this simple structure we’ve covered all of the conditions we need when the user is a VIP. Remember that child actions are not executed unless our condition is met and in our case if its less than 8 hours the switch won’t execute and execute the last Go To instead.

To handle the final condition when the user is not a VIP, we can add a simple Go To outside of our current check. If everything is setup correctly, our flow would look similar to this:

And that’s done! We’ve just built a set of branching rules for our chatbot flow without a single line of code!

Tidy up all actions and operations

Remember that when an operation tree becomes too busy you can click on the operation icon and shrink it so that only a very small preview stays visible! This is a very helpful feature that can save a lot of screen space.

[wpsr_share_icons icons="whatsapp,facebook,twitter,linkedin,email,pdf" icon_size="40px" share_counter="no" icon_shape="drop"]