Creating and saving context variables | Memory Slot

Function and general information

Memory slot is a slot that enables saving data to chat context variables as well as creating new user-declared context variables by saving values to a new, previously non-existent variable.

It is not allowed to change system context variables in the Memory slot except for the client_message variable. Further transfers: Text, Wait For Reaction, Jump, Attachment, File, Memory, External Request, Slot Filling, Button Menu, Transition Rule, Regular Expression, NLU, Change Chat Mode.

Creating and configuring the Slot

Slot’s properties

  • NAME is the name of the slot which will be depicted in the Script Tree;
  • KEY is the name of the variable;
  • VALUE is the value which will be assigned to the variable.

Slot operation

To assign a value to a chat context variable with the use of the Memory slot, specify the name of the variable in the KEY field and the required value in the VALUE field.

Important: All variables are written in text or numeric format only. A number written in single quotes (’45’) is a string and can not be used in arithmetic operations.

  • Writing a numeric value to a variable
  • Writing a string to a variable
  • Writing spaces

Important: Spaces at the beginning or end of the VALUE field will be automatically deleted.

  • Writing the value of one variable to another variable

If you want to write the value of one Chat Context variable to another variable, you need to specify the name of the variable in the VALUE field using the syntax {{ variable_name }}.

For example, if you want to save the last message of the Interlocutor client_message in the Context, the VALUE field will have the value {{ client_message }}

In some cases it is necessary to replace the client_message value with a value different from the last message of the Interlocutor. For example, to recognize text received in an External Request in NLU and Regular Expression slots.

This can be done in the Memory slot. The client_message variable is the only system context variable that can be overwritten.

  • Writing the results of string concatenation to a variable

You can also concatenate several values, including variables, in the Memory slot. To do this, list these variables in the VALUE field in the right order, with a ” + ” symbol.

  • Concatenation of string variables – {{ variable_1 + variable_2 }}
  • Concatenation of string and number variables – {{ ‘variable_1’ + variable_2 }}
  • Concatenation of a string variable and a string – {{ variable_1 + ‘some_text’ }}

Important: The concatenation of the modified_at and date system context variables is not possible because they have the “Date” data type.

Arithmetic operations

You can perform arithmetic operations on numbers in the Memory slot.

Important: Now you can not perform arithmetic operations on variables.

  • Addition

“+” symbol performs both addition and concatenation operations. In the above example numbers are added. However, if you put them in single quotes (i.e. convert them to strings) ‘134’+’1265 ‘, then the concatenation of strings will be performed. The result will be 1341265.

  • Subtraction
  • Multiplication
  • Division

To get the integer part of the division result, the data conversion to integer type is used.

  • Parentheses

Parentheses are used to determine the priority of arithmetic operations.

Important: If you try to add an operation to the VALUE field that does not meet the requirements described above, an error will occur. The error system context variable will take the “Failed to process the data!” value.