# Set Variable Action

This action will attach a new variable to the user profile or update the value of an existing one. Variables can be used to hold values, change chat text and redirect the conversation flow.

![](https://2678899722-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdPD9c4fJbXSAZcPHt9%2F-LfQCHEBAlEibHBxIXB5%2F-LfQCSQtPMzA1alr3nSD%2Fimage.png?alt=media\&token=9eca5afe-731d-43c5-ac86-236cd7e6b2b0)

### Settings

The action uses the following settings:

| Setting       | Description                                                                                                | [Parsed](https://docs10.xenioo.com/actions-and-operations/dynamic-parsing) |
| ------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| Variable Name | The name of the variable you want to create or update. If the variable does not exist, it will be created. | :white\_check\_mark:                                                       |
| Mode          | The update mode of the value                                                                               | :no\_entry:                                                                |
| Value         | The value to be used to set the variable value, according to Mode setting                                  | :white\_check\_mark:                                                       |
| Find          | The value to find inside the variable value, if Mode is Replace                                            | :white\_check\_mark:                                                       |
| Replace With  | The value that will replace the found one, if Mode is Replace                                              | :white\_check\_mark:                                                       |

Mode can have one of the following values:

| Mode                      | Description                                                                                                                                                                                                                                                                        |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Set Value                 | The current value of the variable will be replace with the new one.                                                                                                                                                                                                                |
| Clear                     | The content of the variable will be reset to an empty string. The variable will still exist. If you want to completely remove the variable use the [Delete Variable Action](https://docs10.xenioo.com/actions-and-operations/profile/xenioo.bots.actions.base.dropvariableaction). |
| Replace Value             | Replaces a part of the value of the variable with another given value.                                                                                                                                                                                                             |
| Remove Value              | Removes the specified value from the variable current value.                                                                                                                                                                                                                       |
| Append                    | Appends the specified value to the current variable value. Each appended value is separated by a semicolon (;).                                                                                                                                                                    |
| Concatenate               | Attaches the specified value to the end of the current value without any separator.                                                                                                                                                                                                |
| Uppercase                 | Set all characters in the value to uppercase.                                                                                                                                                                                                                                      |
| Lowercase                 | Set all characters in the value to lowercase.                                                                                                                                                                                                                                      |
| Title Case                | Set all characters in the value to title case, setting all of the first characters in each word to uppercase.                                                                                                                                                                      |
| Reverse                   | Reverse the contents of the value.                                                                                                                                                                                                                                                 |
| Remove Accents            | Removes all accents in the values, replacing them with base letters.                                                                                                                                                                                                               |
| Add                       | Tries to sum the specified value to the current variable value                                                                                                                                                                                                                     |
| Subtract                  | Tries to subtract the specified value from the current variable value                                                                                                                                                                                                              |
| Divide                    | Tries to divide the current variable value by the specified value                                                                                                                                                                                                                  |
| Multiply                  | Tries to multiply the specified value by the current variable value                                                                                                                                                                                                                |
| Normalize to Entity Value | Will try transforming the current variable value to the base value of any entity that is matching.                                                                                                                                                                                 |
| Remove Entity Value       | Will remove from the current variable value all of the given entity values and synonyms.                                                                                                                                                                                           |

### Remarks

If a math operation mode (e.g. Multiply) is used on a variable containing text, the value of the variable will be reset to the specified value. For example if you multiply for 4 a variable containing the value "hello", the variable will contain 4.

The Normalize to Entity Value operation can be used to transform a variable value to the base value of [any entity](https://docs10.xenioo.com/ai/entities) currently defined in the AI section. As an example, let's say you've an entity called city\_name defined like this:

```
new york (ny, big apple)
washington (dc, the capital)
```

Using the Normalize to Entity Value operation on a variable containing "dc" will transform the value to "washington" automatically.

The Remove Entity Value operation will remove every occurrence of a given entity value (and synonyms) from the value. This can be used to quickly remove "noise" words from a sentence.

Variables can be set to contain multi-line text by using newline escaping with \\\r and \\\n.

### Trigger

This action has no triggers.

### Variables

This action does not produce any variable.

### Availability

Channel specific availability follows the table below:

| Channel          | Availability    |
| ---------------- | --------------- |
| Facebook         | Fully Available |
| WhatsApp         | Fully Available |
| Telegram         | Fully Available |
| Web              | Fully Available |
| Alexa            | Fully Available |
| Google Assistant | Fully Available |
| Slack            | Fully Available |
| API              | Fully Available |

This action can be used only inside interactions and not as child of other actions. Any account can use this action regardless of [subscription level](https://docs10.xenioo.com/basic-concepts/your-account/the-free-plan).
