How to implement a lookup table bot variable

Sometimes you need a bot variable which depends on the other bot variable (bot answer) in a way that there’s a corresponding value to the given input, like in the table:

Quriobot allows this via the Script variables.

Step 0: enable developer mode

Step 1: create step variable(s) to be used as input for our lookup:

Step 2: Create a script variable which does the lookup using the other variables:

function(callback, variables) {
  // The `callback` argument has to be called with the result value in order to support the async operations. The `variables` argument is an object containing other variables
  var value = {
     'one': 'one value',
     'two': 'two value'
  }
  callback(value[variables.name.text] || 'default')
}

this is the actual lookup:

-First, it takes the input given in Step 1 (a name question in the example);

-It then applies a lookup table to get the value.

Step 2: use the lookup table in the bot:

Following the example above is the lookup, which can be added as below (like {{lookup}}). This variable can be used in chat texts, response messages, response connections.

Which will then show the lookup table value!

Note: if you want to use input from multiple steps, simply add more variables of the type you need.

If you want to save this lookup along with the response and/or use this lookup results in the advanced conditions for the jump logic or the response connections, you can use the Goto step with the value setting as {{lookup}}:

Edit this page