Variables
Variables Data Types
23 min
what is a variable? 💬 every time you ask a question in the bot and want to store that answer somewhere, you save this answer (value) in a variable think of a variable as a "box" that you can give a name and store "things" inside in this case, those "things" can be values you give to that variable what are the variables format? 📝 some blocks have a format by default, that you can't change nevertheless, it's possible to make operations to change a variable type, but it is easier if you choose the block wisely beforehand 😉 according to the use, you will give to the variable you must choose a specific format for each one, like date, number, string (text), and array string (text) this is the most flexible type of variable it is usually used to save text inside it, but you can also add numbers, dates, signs, emojis, hyperlinks, etc number here you can only save numbers, not symbols or letters date save dates inside these variables (please note that you can't save dates inside a webhook block) array an array is a data structure that contains a group of elements typically these elements are all of the same data type, like a string or number an array variable is very handy if you are a developer or if you want to try out more of our technical features and workarounds objects to use an object in landbot you'll need to save it as array data type data types not available in landbot boolean you can't create or save variables in this type due this is a system variable that is used only in a condition block to check if the agents are online null landbot can't parse null values and will return an error how do the variables work? 🧐 as the name says itself, the value you save inside a variable may change according to the answer given by the user, or the choices made throughout the bot flow to create a variable select a block and add it to the builder scroll down to save answers in the field name the variable whatever you want, but note that it must always have @ (symbol) before the name choose the format of the variable (number, string, date, array) and save it tip the name you assign your variable should be accurately descriptive and understandable to another teammate in your account 😉 example 1 if i want to ask for the user's name (value) and save it in the variable @name you can create or customize a variable in a block, in the save answers in the variable > custom variables subsection of each block when 2 different users go through the bot flow, the variable will have the same name ( @name ), but the value will be different for each user as you can see in this example, the variable where we store the name of the user is the same, saved under the name @name but the value stored in it will change according to what each user answers so @name = maria @name = paul example 2 in the next button block, the answer will be saved in the variable @testing then we will use the variable @testing in a message block, to inform the user which option has been chosen before to add the variable to the block, we have two options write @testing in the send a message block click on the variables option of the send a message block (variables list), and choose the variable write testing and choose the correct custom variable click on the variable testing, then the result will look like this now, the final view in the chatbot will be, according to the choice of the user in the buttons block landbot's system variables types landbot has its own variable system the bot will save each and every data collected by the bot in a variable note apart from the case of the welcome message variable name, all the other variable names are editable you can use the variables to recall data and pipe it into a new block and most importantly to study the information collected in the analyze section of the builder let's discover now what kind of variables are available on landbot lead data variables id \[number] by default, it's a unique id number set up by the system (example 8029448); note it will remain the same id if you have activated the second visit to always continue the conversation or provide buttons to start again or continue name \[string] by default it's the #visitor & the id variables (example visitor #8029448); email \[string] empty by default; company \[string] empty by default; phone \[string] empty by default usage details variables last seen \[date] last time the visitor id has been seen by the bot, format yyyy mm dd (example 2019 03 06); created \[date] when the visitor id was created, format yyyy mm dd (example 2019 03 06); url \[string] it is the url where the bot is located (example https //landbot io/u/h 145130 z1wucm98qr4y2la7/index html); browser \[string] if detected; device \[string] if detected; os \[string] if detected; country \[string] if detected (example italy) time reference variables dates are based on central european time / european central time (standard time) cet yesterday \[date] format yyyy mm dd (example 2019 03 05); today \[date] format yyyy mm dd (example 2019 03 06); tomorrow \[date] format yyyy mm dd (example 2019 03 07) lock = system variables that can be overwritten by landbot custom variables welcome \[string] welcome variable stores the input from the visitor in the welcome message (example hello!) for web the variables @country , @browser , @device , and @os will be collected by default for whatsapp the variables @name and @phone will be collected by default, however, the variable @name will save the name that the user has in his whatsapp, not their real name the variables @browser , @device , and @os will not be collected by default for facebook messenger the variables @name, @phone, @browser , @device , and @os will not be collected by default display images with a variable containing a url source, as you can see in this https //help landbot io/article/498dycfc3y how to display images or other media with a variable source make a counter for variables you can find further information about it in this https //help landbot io/article/bugyvw4l4h builder 3 how to make a counter for variables or this https //landbot io/u/h 154619 i5tc63uzt3g4ixrr/index html 🤩 additional information ⚠️ it's not possible to leave a variable without values it's not possible to drop variable if the variable has a value and you want to give it another value or change the format, you can use the set a variable block to do it if you find a blank variable list it's because the user didn't answer the question that had that variable arrays have a limit of 1mb anything more will cause errors in the dynamic data block