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:
![](https://academy.quriobot.com/how-to-build-an-advanced-bot/how-to-implement-a-lookup-table-bot-variable/27551.en-us_huef487fdf9f6da2353fc9caea958688c4_252592_20x0_resize_box_3.png)
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:
![](https://academy.quriobot.com/how-to-build-an-advanced-bot/how-to-implement-a-lookup-table-bot-variable/27552.en-us_hu5b7dde28f9235a55d72fe7641b175cec_67898_20x0_resize_box_3.png)
Step 2: Create a script variable which does the lookup using the other variables:
![](https://academy.quriobot.com/how-to-build-an-advanced-bot/how-to-implement-a-lookup-table-bot-variable/27553.en-us_huee86e4c72b1c8553de25d2d535a5a80e_141367_20x0_resize_box_3.png)
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.
![](https://academy.quriobot.com/how-to-build-an-advanced-bot/how-to-implement-a-lookup-table-bot-variable/27554.en-us_hu5702a41c15e46ee3ab6eaea3d49fb5aa_71445_20x0_resize_box_3.png)
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}}:
![](https://academy.quriobot.com/how-to-build-an-advanced-bot/how-to-implement-a-lookup-table-bot-variable/27555.en-us_hudc7a7da5161b3840becce0a613ee0d4f_167648_20x0_resize_box_3.png)
![](https://academy.quriobot.com/how-to-build-an-advanced-bot/how-to-implement-a-lookup-table-bot-variable/27556.en-us_hu15f0851330cc4d97f0aa5afa6fb1d982_294425_20x0_resize_box_3.png)