QiChatVariable


level_1


What is it

A QiChatVariable represents a variable in a QiChat Topic. It allows the exchange of data between java code and QiChat scripts.

For further details, see:

How to use it

Retrieving a variable

Get a QiChatVariable from a QiChatbot containing the topic where the variable is defined:

QiChatbot qiChatbot = ...;
QiChatVariable nameVariable = qiChatbot.variable("name");

Reading/Writing a variable

Read and write a QiChatVariable and set a listener to handle a value change:

QiChatVariable nameVariable = ...;

nameVariable.setValue("Pepper");
String name = nameVariable.getValue();
nameVariable.addOnValueChangedListener(currentValue -> Log.i(TAG, "onValueChanged: " + currentValue));