Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmenger committed Sep 26, 2023
1 parent 309b1c5 commit 16e43cc
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions pages/docs/conversationPatterns/arrayVariables/arrayVariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Wingbot.ai also supports array as variables.
### Create an array `[...] set`

- `[...] set | Foo` set a single value to array 👇
```
```json
"varName": ["Foo"]
```
- `[...] set | ` set an empty value to array 👇
```
```json
"varName": []
```

Expand All @@ -26,39 +26,38 @@ Wingbot.ai also supports array as variables.
### Add a unique item to array `[]+ add`

- `[]+ add | Bar` - value doesn't exists, so it'll be added
```
```json
"varName": ["Foo"]
"varName": ["Foo", "Bar"]
```

- `[]+ add | Foo` - value exists, so the array will remain unchanged
```
```json
"varName": ["Foo"]
"varName": ["Foo"]
```
### Remove an item from array `[]- remove`

- `[]- remove | Bar` - value doesn't exists, so it'll be added
```
```json
"varName": ["Foo", "Bar", "Baz", "Bar"]
"varName": ["Foo", "Baz"]
```

- `[]- remove | Bar` - value doesn't exists, so the array will remain unchanged
```
```json
"varName": ["Foo"]
"varName": ["Foo"]
```

```
### Push item to array `[]<- push` (to the right)

- `[]<- push | Bar` - just adds an item, no matter it exists or not
```
```json
"varName": ["Foo", "Bar"]
"varName": ["Foo", "Bar", "Bar"]
Expand All @@ -67,7 +66,7 @@ Wingbot.ai also supports array as variables.
### Pop item from an array `[]-> pop` (from the right)

- `[]-> pop` - just removes the most right item
```
```json
"varName": ["Foo", "Bar"]
"varName": ["Foo"]
Expand All @@ -76,7 +75,7 @@ Wingbot.ai also supports array as variables.
### Shift item from an array `<-[] shift` (from the left)

- `<-[] shift` - just removes the most left item
```
```json
"varName": ["Foo", "Bar"]
"varName": ["Bar"]
Expand All @@ -85,61 +84,61 @@ Wingbot.ai also supports array as variables.
## Values, which can be put into an array

- **plain text** (strings) - `[...] set | Foo`
```
```json
"varName": ["Foo"]
```

- **lists** - `[...] set | Foo, Bar\, Baz`
```
```json
"varName": ["Foo", "Bar, Baz"]
```

- **variables** - `[...] set | {{someVar}}`
```
```json
"someVar": "Foo"
"varName": ["Foo"]
```

- **input text** - `[...] set | {{$input}}`

**users message:** `hello!`
```
```json
"varName": ["Hello"]
```

- **text of quick reply** - `[...] set | {{$this}}` - works only inside a quick reply

**quick reply:** `(Show me more!)`
```
```json
"varName": ["Show me more!"]
```

- **other arrays** - `[...] set | {{someVar}}`
```
```json
"someVar": ["Foo", "Bar"]
"varName": ["Foo", "Bar"]
```

- **entities** - `[...] set | {{@email}}` - *when there are more occurrences of the entity, all values will be inserted*

**users message:** `send it to foo@mail.com and to bar@mail.com`
```
```json
"varName": ["foo@mail.com", "bar@mail.com"]
```

## Using arrays in chat messages

Let's have an array like this

```
```json
"varName": ["Foo", "Bar", "Baz"]
```

- **list items**

*message input*

```
```handlebars
{{#each varName}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}
```

Expand All @@ -153,7 +152,7 @@ Let's have an array like this

*message input*

```
```handlebars
{{#if varName}}with items{{else}}empty{{/if}}
```

Expand All @@ -167,7 +166,7 @@ Let's have an array like this

*message input*

```
```handlebars
{{varName}}
```

Expand All @@ -181,7 +180,7 @@ Let's have an array like this

*message input*

```
```handlebars
{{varName.[0]}}
```

Expand All @@ -194,7 +193,7 @@ Let's have an array like this

*message input*

```
```handlebars
{{varName.length}}
```

Expand All @@ -212,6 +211,6 @@ Let's have an array like this

## Example - messages sequence

![Designer](image-2.png)
![Chat](image-1.png)

![Chat](image-1.png)
![Designer](image-2.png)

0 comments on commit 16e43cc

Please sign in to comment.