+55 (21) 960104492
Log In Free trial
Select region

Changing variable block

A variable is a storage that has a name and contains a value. Use variables in the script to create a unique personalized dialogue for each client. For example, you can write a system variable {{name}} so that during the dialog the bot will substitute the name from the messenger in this place.

But what if we want to use information about the client that is not in the system variables? Using the "Change Variable" block, you can substitute the value you want into the variable you created. There are several options where this can be useful.

Variant 1: Universal Message Template

Let's say we need information about a client in a dialog - contract number, number of employees in the company and the city where the client is located.

1) We create local variables with Latin characters: contract_num, employees, city (you can invent your own).

2) We create a message sending block and write in the text: "Can you tell me your contract number?". 

3) Link it to the "Wait for message" block and then create "Change Variable". 

4) Select the variable we want to change (contract_num).

5) In the "Change to" field, type {{message}}. This way the bot will substitute the text of the message sent to us by the client into the variable value.

6) Repeat this action with all created variables.

7) Now you will be able to use the values that the bot will write to these variables when the client writes a message. Example: "Let's check everything out. The company is located in {{city}} and has {{employees}} employees. Your contract number is {{contract_num}}. Is this correct?"

Variant 2: Changing the variable type

Every variable has a type - a string or an integer. The type of the variable determines what data it can store and how other blocks will treat this variable. For example, in the "Condition" block you can't check for more or less than a variable with the value type "String", but you can check for an integer.

This comes in handy if you want to test for a greater than/less than condition on a client message, since the {{message}}(message) variable is a string.

1) In the scripting process, create a "Send Message" block where you request an integer from the client.

2) Create a block "Waiting for message" and then "Change variable".

3) Create a local variable with the value type "Integer" and give it Latin characters.

4) In the "Change Variable" block, select the created variable and type {{message}} in the "Change to" field. This way the bot will substitute the value from the client's message into the created variable and you will be able to check it in the "Condition" block.

Video Tutorial

If you still have questions, watch the video "Change Variable block"

Leave a request for integrator services