Skip to content

Getting started

The Botsquad chatbot language (Bubblescript) is a simple programming language you use to program chatbots in the Botsquad studio. This introduction helps you get started with building your own chatbot.

Simple example

Lets start off with a simple example, a script that will tell a joke to the person interacting with the bot. We will expand on the Bubblescript language in the following sections.

Press "Run" to see this bot in action!

We'll take the example line-by-line and explain what is going on.

dialog main do


This line indicates the start of a dialog. Dialogs are the main building blocks of bot conversations. They contain interactions with the user, grouped together and ran in sequence, one after the other. The main interactions are say, ask and show. But more about that later.

main is the name of the dialog. All Bubblescript scripts must have a dialog with the name main as this is the starting point for the bot.

Then we have the word do. This words indicates the start of a do..end block, which ends with the word end. Everything inside the block will automatically be indented.

type 1

Here we have our first statement. This is used to display a typing indicator to the user. The 3 after type indicates how long it should be displayed, measured in seconds.

say "To the optimist, the glass is half-full."
say "To the pessimist, the glass is half-empty."
say "To the engineer, the glass is twice as big as it needs to be."

Now we start to talk to the user of our bot using the say statement. The text in between the double quotes (" ") is what will be displayed to the user in a text bubble.

pause 2

This is another statement that tells the bot to wait for an amount of time, without showing a typing indicator.

ask "Did you laugh?", quick_replies: ["Yes", "No"], expecting: ["Yes", "No"]

With the ask statement we can ask the user something. The script will pause at this point waiting for user input. This input is stored in the variable answer.

The answer variable is is re-used between asks and will always contain the answer from the last ask

The expecting: ["Yes", "No"] indicates that the we expect the user to answer with either "Yes" or "No". If the user responds with an answer that does not match the expectation, the question is asked again until the expected response is matched. It actually first will try to find other dialogs that match the input before returning to the ask. More about this in the dialog resolution section later.

The quick_replies: option will show Yes/No buttons below the question.

Note the , after the quoted question. Optional arguments are separated from the main argument by a comma.

branch answer do
  "Yes" ->
    say "You must be an engineer!"
  "No" ->
    say "You're not an engineer are you?"

Here we see another do .. end block, but this time with branch as statement. With branch we can decide what to do next based on a condition (logical expressions). If answer == "Yes" evaluates to true, then we move on to the line after the ->. There we find say "You must be an engineer!". The conditions are evaluated top down and the first one that evaluates to true is executed, others after it are not considered.