Array variables
Wingbot.ai also supports array as variables.
Operations: what to do with an array
Create an array [...] set
[...] set | Fooset a single value to array 👇"varName": ["Foo"][...] set |set an empty value to array 👇"varName": []
When there is already some data in variable, it will be overwritten
Add a unique item to array []+ add
[]+ add | Bar- value doesn't exists, so it'll be added"varName": ["Foo"]⇩"varName": ["Foo", "Bar"][]+ add | Foo- value exists, so the array will remain unchanged"varName": ["Foo"]⇩"varName": ["Foo"]
Remove an item from array []- remove
[]- remove | Bar- value doesn't exists, so it'll be added"varName": ["Foo", "Bar", "Baz", "Bar"]⇩"varName": ["Foo", "Baz"][]- remove | Bar- value doesn't exists, so the array will remain unchanged"varName": ["Foo"]⇩"varName": ["Foo"]
Push item to array []<- push (to the right)
[]<- push | Bar- just adds an item, no matter it exists or not"varName": ["Foo", "Bar"]⇩"varName": ["Foo", "Bar", "Bar"]
Pop item from an array []-> pop (from the right)
[]-> pop- just removes the most right item"varName": ["Foo", "Bar"]⇩"varName": ["Foo"]
Shift item from an array <-[] shift (from the left)
<-[] shift- just removes the most left item"varName": ["Foo", "Bar"]⇩"varName": ["Bar"]
Values, which can be put into an array
plain text (strings) -
[...] set | Foo"varName": ["Foo"]lists -
[...] set | Foo, Bar\, Baz"varName": ["Foo", "Bar, Baz"]variables -
[...] set | {{someVar}}"someVar": "Foo""varName": ["Foo"]input text -
[...] set | {{$input}}users message:
hello!"varName": ["Hello"]text of quick reply -
[...] set | {{$this}}- works only inside a quick replyquick reply:
(Show me more!)"varName": ["Show me more!"]other arrays -
[...] set | {{someVar}}"someVar": ["Foo", "Bar"]"varName": ["Foo", "Bar"]entities -
[...] set | {{@email}}- when there are more occurrences of the entity, all values will be insertedusers message:
send it to foo@mail.com and to bar@mail.com"varName": ["foo@mail.com", "bar@mail.com"]
Using arrays in chat messages
Let's have an array like this
"varName": ["Foo", "Bar", "Baz"]
list items
message input
,output
Foo, Bar, Bazcheck if an array is empty
message input
with itemsemptyoutput
with itemssimply show array items
message input
output
Foo,Bar,Bazaccess the first item
message input
output
Foohow much items are in the array
message input
output
3