In this help doc, we explain you advanced option available in the Conditional Jump Feature. If you do not know about this feature check the basics of it first here.

How does Conditional Jump actually work

So how does the bot decide which branch to take? This is where the magic happens.

Each branch contains a set of conditions. You can take a value from elsewhere in the flow (e.g. a user response or data from an api call) and check to see whether it meets those conditions.

(To see how to refer to data from elsewhere in your flow check double brace syntax.)

The Bot starts from the first Branch (Top most/Left most) and checks for all the conditions that you have set. It will then simply jump to the first branch for which conditions are met. A branch giving true means that the conditions within that branch are satisfied. Jumping to that branch means it will follow the direction of that branch (i.e. wherever you connected the corresponding socket).

Are you more confused now than before?

If so take the example from above:

Over here we are checking the user response from a gambit named gid_1, hence the value we are comparing is {{ursp.gid_1}}.

In the first branch we check if {{ursp.gid_1}} is less than OR equal to 20000. In the 2nd Branch has conditions to check if the user response on gambit gid_1 is greater than 20000 AND less than 50000. The third and final branch is a default branch, more on this in about two paragraphs.

The system checks each branch in order from top to bottom. So in the above example it will take the first branch and check whether {{ursp.gid_1}} is less than 20000 or equal to 20000. If the response meets these conditions, it will not check branch 2 and push the conversation in the direction of branch 1 (i.e. wherever you connected the socket corresponding to branch 1). If it doesn’t meet this condition, it will check branch 2. If it does meet the conditions in branch 2, the conversation will move in the direction of branch 2 (i.e. wherever you connected the socket corresponding to branch 2).

But what if it meets neither of these conditions? What if in the above example {{ursp.gid_1}} is 60,000? It is not less than or equal to 20,000 so branch 1 will not be activated. It is not in between 20,000 and 50,000 so branch 2 will not be activated. This is where the default branch comes into play. The default branch is a fallback. If the bot checks every branch that you have created and none of them are activated, then the bot will send you in the direction of the default branch.


AND/OR

With conditional jump feature, you can check multiple conditions in a single branch (in branch two we check if the number is above 20000 and below 50000). The way you can do this is using the AND/OR operator within the branch:

The way this works is as you’d expect. If you have two conditions in a branch condition A and condition B. If a branch calls for condition A AND condition B, then the value being compared has to satisfy condition A and condition B (i.e. the user response has to be both greater than 20000 AND less than 50000).

If a condition calls for condition A OR condition B, then the value being compared has to satisfy either condition A OR condition B. Take the following example:

If {{ursp.gid_1}} is 30000 this branch will not be activated. If {{ursp.gid_1}} is 10000 this branch will be activated. If {{ursp.gid_1}} is 60000 this branch will be activated.

What if there are more than two conditions?

Like this:

ANDs always get grouped together. This means that in the above example {{ursp.gid_1}} has to either be less than 20000 OR between 50000 AND 700000. Consider the following test values:

10000 will activate this branch

60000 will activate this branch

30000 will NOT activate this branch

Think about it this way: when you have AND statements continuously, put a pair of parentheses around all the AND conditions. Consider the following set up:

This would be evaluated as:

condition A OR (condition B AND condition C AND condition D AND condition E) OR condition F

Or {{ursp.gid_1}} has to be less than 3000 OR (between 5000 AND 500000 AND NOT equal to 300000 AND NOT equal to 400000) OR greater than 700000

Consider the following test terms:

2000 -> branch activated

4000-> branch NOT activated

7000 -> branch activated

250000 -> branch activated

300000 -> branch activated

800000 -> branch activated

Comparison Operators

Broadly speaking you can make two types of comparison. Number comparisons and String comparison.

Number comparison is used when you want to check a number input that the user has submitted. Like all of the examples above. Within number comparison you can check the whether a value is equal to, not equal to, less than or greater than a specific value. Check the examples above again, I have used all of them at some point.

With String Comparison, you can compare pieces of text. So if a user response is a piece of text (say a city name) using the auto-suggestion feature, you could check to see what city the user typed in using the string comparison.

So what operators do you have access to within String comparison?

Is, Is not, Contains, Not contains.

These operators are fairly self explanatory, but here is a quick run down

Look at the following setup to check the name input by a user:

Contains Operator checks to see if the value you want to check contains a specified string. In the above example, the condition in branch 1 checks to see whether {{ursp.gid_1}} (i.e. the user response in the gambit named gid_1) contains singh. If {{ursp.gid_1}} does contain singh, then branch 1 is activated.

Is Operator checks to see if the value you want to check is a specified string. In the above example, the condition in branch 2 checks to see whether {{ursp.gid_1}} is Ish. If it is Ish, then branch 2 is activated

Not Contains Operator checks to see if the value you want to check does not contain a specified string. In the above example, the condition in branch 3 checks to see whether {{ursp.gid_1}} does not contain raj. If it does not contain raj, branch 3 is activated.

Is not Operator checks to see if the value you want to check is not a specified string. In the above example, the condition in branch 3 checks to see whether {{ursp.gid_1}} is Vinit. If it is NOT Vinit, branch 3 is activated.

If you are still confused, do check out these three examples we made:

  1. In the first example, we show how a food ordering bot could use conditional jump to figure out which city the customers live in. Accordingly, it customises the conversational flow, making the experience more personal thus enhancing the user experience: https://convbot.hellotars.com/conv/r1X-Rb/
  2. This second example shows how an loan agency for example can check to see what range a user’s salary falls into and accordingly take them in a different conversational direction (i.e. show them a different interest rate): https://convbot.hellotars.com/conv/r1X-Rb?_startgid=10
  3. The third example shows how any company can use conditional jump to check coupon codes and give loyal customers rewards within their bots. Try using any of the following coupon codes: COUPONS4EVA, COUPONZ4LYF, COUPONS4COUPONS, COOPY1956. Providing these codes will unlock a prize. Not doing so… well… - https://convbot.hellotars.com/conv/r1X-Rb?_startgid=24

If you need any help for this or anything else, please feel free to reach out by support chat on bottom right.

Did this answer your question?