> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guide/variables/set-variable.md).

# Set variable

This is the action used to create or change the value of a variable (data container) in the script. Additionally, this action allows you to create input fields right on the main interface, enabling users to fill in information before starting to run the tool.

* Allow user input from the interface: You check this option to create empty fields on the main screen, allowing users to directly enter values into the script before clicking run.
* Input required: When this option is selected, the system will require users to fill in all data or select a file before allowing them to click the run button. If left empty, the tool will report an error immediately to avoid running mistakenly due to forgotten input.

🎥 Watch the tutorial video: [Here](https://youtu.be/nlEQsaxawt4).

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-130c2652cf602529a79538c92b8bfe0398191be7%2Fva-01.png?alt=media" alt=""><figcaption></figcaption></figure>

The system supports 4 types of input data (Input Type) on the interface, including:

#### 1. Text Input Type

Used when you want users to manually enter a string, text, or number from the keyboard.

* Real example: You name the variable `$textContent`. When the user enters the content `"hello world"` into the input field on the interface, the value of the variable `$textContent` will be `"hello world"` (`$textContent = "hello world"`).

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-4783e545fce2cce4d6234ceefdd7660b23c2185b%2Fva-01b.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-bbebe89d7c5e8a036b47dd183d2102fa0280979b%2Fva-01c.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 2. File Input Type

Used when the script needs to process a specific file on the user's computer (such as an image file, data file, configuration file...). A folder icon button will appear on the UI for users to click and browse for the file.

* Real example: The user selects a file named `bruh.png` located on drive D. The value of the variable `$filePath` will be the absolute path of that file: `"D:\materials\bruh.png"` (`$filePath = "D:\materials\bruh.png"`). You can immediately use this `$filePath` variable to pass into the File upload action in subsequent steps.

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-a84c5e76d7f3372c746b4f76ac356c216f368cef%2Fva-01d.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-265ec789c60ada64a861f7daf2619904709488d8%2Fva-01e.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 3. Checkbox Input Type

Checkbox is a UI component that allows users to toggle a binary option (yes/no, on/off, agree/disagree).

* Characteristics: When checked, the variable will have the value `True`. When unchecked, the variable will have the value `False`.
* Real example: You create an item labeled *"Check to place an order"* associated with the variable `$checkBox`. If the user checks this box, the variable `$checkBox` will have the value `True` (`$checkBox = True`). You can use an If block to check: if `$checkBox = True`, then proceed with the payment steps.

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-810446a14ecee9ffddff6b73b7648111aad19b09%2Fva-01f.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 4. Combo Box Input Type

Combo Box (similar to Dropdown) is a UI component that displays a list of available options, allowing users to select a single value at a time. This feature helps minimize the risk of misspelling or incorrect data formatting.

* Characteristics: Helps maintain consistent data when selecting fixed information such as Country, Industry, Product Type, Operational Status...
* Real example: You configure a list of multiple countries associated with the variable `$country`. When the user opens the script and selects `"United States"` from the dropdown list, the variable `$country` in Automate will immediately receive the value `"United States"` (`$country = "United States"`).

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-530e576ba157108ca6d2f065a3023e035f952a5e%2Fva-01g.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-0794bfdcb7a18c5fa334183c29de77bc851e245f%2Fva-01h.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gpmautomate.com/automate-en/action-guide/variables/set-variable.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
