Skip to main content
MindStudio
Pricing
Blog About
My Workspace
Workflow Logic

Set Variable

The Set Variable block explicitly assigns a value to a named variable within a workflow.

Assign a value to any workflow variable

The Set Variable block explicitly assigns a value to a named variable within a workflow. It takes two primary inputs: a destination variable name and a value to assign, both of which support dynamic variable interpolation. The value can be a plain string or an array of strings, and an optional type field provides a UI hint in the editor to control how the input widget is rendered — options include plaintext, imageUrl, videoUrl, fileUrl, textArray, imageUrlArray, and videoUrlArray.

Once the block executes, it returns the resolved variable name that was set and the resolved value that was assigned. This makes it straightforward to confirm what was written, especially when the variable name or value was constructed dynamically from earlier steps in the workflow.

This block fits into workflows where you need to initialize, overwrite, or carry forward a specific value — for example, storing a user input for later reference, setting a default before a conditional branch, or capturing a computed result as a named variable that downstream blocks can read.

What you can build

Real-world workflows powered by the Set Variable block.

Initialize Default Values

Set a default value for a variable at the start of a workflow before any conditional logic runs, ensuring downstream blocks always have a defined input to work with.

Store User Input

Capture a value entered by a user and assign it to a named variable so it can be referenced consistently across multiple later steps in the workflow.

Track Workflow State

Update a status variable at key points in a workflow to track progress, such as marking a step as complete before moving to the next branch.

Build Dynamic Prompts

Assign a dynamically constructed string — built from earlier outputs — to a variable that will be passed into an AI prompt block later in the workflow.

Store Media URLs

Assign an image, video, or file URL returned by a previous block to a named variable using the appropriate URL type hint, making it available for display or processing steps.

Accumulate Array Values

Set a variable to an array of strings — such as a list of collected items or responses — so that downstream blocks can iterate over or display the full set.

Ready to add Set Variable to your workflow?

Get Started Free

Common questions about Set Variable

What are the required parameters for the Set Variable block?

The two required parameters are destinationVariableName, which specifies the variable to set, and value, which is the string or array of strings to assign. Both fields support variable interpolation, meaning you can reference other variables when constructing either the name or the value.

What does the Set Variable block return?

The block outputs two fields: variableName, which is the resolved name of the variable that was set, and value, which is the resolved value that was assigned. These reflect the final interpolated results after any dynamic references are evaluated.

What is the type field used for?

The type field is a UI hint only and controls which input widget appears in the editor. It does not affect runtime behavior. Supported values are plaintext, imageUrl, videoUrl, fileUrl, textArray, imageUrlArray, and videoUrlArray.

Can the variable name itself be dynamic?

Yes. The destinationVariableName field supports variable interpolation, so you can construct the target variable name from values produced earlier in the workflow rather than hardcoding a fixed name.

What kinds of workflows commonly use this block?

The Set Variable block is commonly used in workflows that need to initialize constants before branching logic, store intermediate results for reuse, carry user inputs forward across multiple steps, or assign media URLs for later display or processing.

Add Set Variable to your workflow

Build powerful AI workflows with drag-and-drop blocks. No coding required.