Array variables
Wingbot.ai also supports array as variables.
Operations: what to do with an array
[...] set
Create an array [...] set | Foo
set 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
Add a unique item to array []+ 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
Remove an item from array []- 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
(to the right)
Push item to array []<- push | Bar
- just adds an item, no matter it exists or not"varName": ["Foo", "Bar"]⇩"varName": ["Foo", "Bar", "Bar"]
[]-> pop
(from the right)
Pop item from an array []-> pop
- just removes the most right item"varName": ["Foo", "Bar"]⇩"varName": ["Foo"]
<-[] shift
(from the left)
Shift item from an array <-[] 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