Skip to content



Conditionals can be used to decide what the bot should do based on input it receives or the state that it is in at a given moment. Bubblescript supports several methods of describing these conditions. The preferred method is a branch. Conditionals are written down with the aid of logical expressions in the form of predicates. The following operators can be used to write logical expressions:

The following operators can be used:

  a && b    # AND
  a || b    # OR
  a !  b    # NOT
  a == b    # IS
  a != b    # IS NOT
  a <= b    # IS SMALLER OR EQUAL TO
  a >= b    # IS LARGER OR EQUAL TO
  a <  b    # IS SMALLER
  a >  b    # IS LARGER


The branch statement evaluates each expression top down until the first one that evaluates to true. The expressions are seperated by -> and then 1 or multiple lines of indented code that is executed sequentially.

This is especially handy if you want to check more than two predicates:

  ask "Do you want to continue?", expecting: ["Yes", "No", "Maybe"]
  branch do
    answer == "No" ->
      say "Sorry to hear"
    answer == "Yes" ->
      say "Great!"
    answer == "Maybe" ->
      say "Make up your mind!"

In the above example the expecting: assures that answer can only contain the 3 cases we branch on. If you branch on an open answer you can end with a catch all true case:

  ask "What is your name?"
  branch do
    answer == "Steve" -> say "hi Steven"
    answer == "Pete"  -> say "hi Peter"
    true              -> say "hi stranger"


To allow the bot to make decision based on the users input the statement if and else used to conditionally execute blocks of code with if you can test for truthiness of a condition (predicate).

  if platform == "Yes" || app == "Yes" do
    say "Apps or platforms are not really a thing anymore."

Reads: "If variable platform is equal to "Yes" and variable app is equal to "Yes" do the following"


Executes the else block if the if statement evaluates to false (is not true).

  if exits != "Yes" do
    say "I believe in your product. Let's do it!"
    if team > 3 do
      say "I think your team is too big."
      if platform == "Yes" || app == "Yes" do
        say "Apps or platforms are not really a thing anymore."