Skip to main content

What are Variables?

Variables in Flowise are global, reusable values that can be referenced across multiple chatflows and agentflows. They provide a way to:
  • Store configuration values used across multiple flows
  • Dynamically change flow behavior without editing nodes
  • Separate environment-specific settings (dev, staging, production)
  • Reference system environment variables from .env files
Variables are not encrypted like credentials. Only use variables for non-sensitive configuration data.

Why Variables Matter

Variables improve maintainability and flexibility:
  • Centralized Configuration: Update one variable to affect all flows using it
  • Environment Management: Different values for dev/staging/production
  • Reusability: Define once, use everywhere
  • Runtime Flexibility: Change behavior without redeploying flows
  • Experimentation: Test different prompts, temperatures, or parameters

Variable Structure

Database Schema

{
  id: string              // UUID
  name: string            // Variable name (e.g., "DEFAULT_MODEL")
  value: string           // Variable value
  type: string            // "static" | "runtime"
  createdDate: Date
  updatedDate: Date
  workspaceId: string     // Workspace association
}

Variable Types

Flowise supports two variable types:

1. Static Variables

Static variables store values directly in Flowise’s database.
{
  name: "DEFAULT_TEMPERATURE",
  value: "0.7",
  type: "static"
}
Use cases:
  • Prompt templates
  • Default model parameters
  • System messages
  • Configuration strings
  • Thresholds and limits

2. Runtime Variables

Runtime variables reference environment variables from your .env file.
{
  name: "ORGANIZATION_NAME",
  value: "COMPANY_NAME",  // Reads from process.env.COMPANY_NAME
  type: "runtime"
}
Use cases:
  • API endpoints that change per environment
  • Deployment-specific settings
  • Container/server configuration
  • Secrets that shouldn’t be in the database
Runtime variables are read from process.env at execution time, making them perfect for containerized deployments.

Variable Type Comparison

FeatureStaticRuntime
StorageDatabaseEnvironment (.env)
Editable in UI✅ Yes✅ Yes (name only)
Update PropagationImmediateRequires restart
Use CaseUser-configurable valuesDeployment configuration
SecurityNot encryptedCan be secured via secrets manager

Creating Variables

From the UI

  1. Navigate to Variables page
  2. Click Add Variable
  3. Fill in the form:
    • Name: Variable identifier (e.g., DEFAULT_MODEL)
    • Type: Select “Static” or “Runtime”
    • Value:
      • Static: Enter the actual value
      • Runtime: Enter the environment variable name
  4. Click Add
// Variable creation logic from source
const variableTypes = [
  {
    label: 'Static',
    name: 'static',
    description: 'Variable value will be read from the value entered below'
  },
  {
    label: 'Runtime',
    name: 'runtime',
    description: 'Variable value will be read from .env file'
  }
]

const addNewVariable = async () => {
  const obj = {
    name: variableName,
    value: variableValue,
    type: variableType  // "static" or "runtime"
  }
  const createResp = await variablesApi.createVariable(obj)
  if (createResp.data) {
    enqueueSnackbar({ message: 'New Variable added', variant: 'success' })
  }
}

Via API

# Create a static variable
curl -X POST http://localhost:3000/api/v1/variables \
  -H "Content-Type: application/json" \
  -d '{
    "name": "DEFAULT_MODEL",
    "value": "gpt-3.5-turbo",
    "type": "static"
  }'

# Create a runtime variable
curl -X POST http://localhost:3000/api/v1/variables \
  -H "Content-Type: application/json" \
  -d '{
    "name": "API_BASE_URL",
    "value": "FLOWISE_API_URL",
    "type": "runtime"
  }'

Using Variables in Flows

Syntax

Reference variables using double curly braces:
${{variableName}}

In Node Parameters

Variables can be used in any text input field: Example: Model Selection
// ChatOpenAI node configuration
{
  modelName: "${{DEFAULT_MODEL}}"  // Resolves to "gpt-3.5-turbo"
}
Example: Temperature Setting
{
  temperature: "${{DEFAULT_TEMPERATURE}}"  // Resolves to "0.7"
}
Example: System Prompt
{
  systemMessage: "You are a helpful assistant for ${{COMPANY_NAME}}. Today is ${{CURRENT_DATE}}."
}

In Prompt Templates

// Prompt Template node
{
  template: `
You are an AI assistant for ${{COMPANY_NAME}}.

Guidelines:
- Be ${{TONE_STYLE}}
- Keep responses under ${{MAX_WORDS}} words
- Use examples from ${{INDUSTRY_DOMAIN}}

User question: {question}
`
}

Autocomplete Support

Flowise provides autocomplete for variables:
// From source: suggestionOption.js
export const refreshVariablesCache = async () => {
  const variables = await variablesApi.getAllVariables()
  // Cache for autocomplete suggestions
  variableCache = variables.map(v => ({
    label: v.name,
    value: `${{${v.name}}}`,
    type: v.type
  }))
}

// When user types "${{" in input field, show suggestions
Type ${{ in any text field to see autocomplete suggestions for available variables.

Variable Resolution

Static Variable Resolution

// At runtime
let nodeParam = "${{DEFAULT_MODEL}}"

// Flowise looks up variable
const variable = variables.find(v => v.name === "DEFAULT_MODEL")

// Replaces with value
nodeParam = variable.value  // "gpt-3.5-turbo"

Runtime Variable Resolution

// Variable definition
{
  name: "API_ENDPOINT",
  value: "OPENAI_BASE_URL",  // References env var
  type: "runtime"
}

// At runtime
let nodeParam = "${{API_ENDPOINT}}"

// Flowise reads from environment
const envValue = process.env.OPENAI_BASE_URL
nodeParam = envValue  // "https://api.openai.com/v1"

Multiple Variables

You can use multiple variables in a single field:
{
  systemMessage: "Welcome to ${{COMPANY_NAME}}! Today is ${{CURRENT_DATE}}. Our policy is ${{POLICY_LINK}}."
}

// Resolves to:
// "Welcome to Acme Corp! Today is 2024-03-04. Our policy is https://acme.com/policy."

Managing Variables

Viewing Variables

The Variables page displays a table with:
  • Variable name
  • Current value
  • Type badge (Static/Runtime)
  • Last updated date
  • Created date
  • Action buttons (Edit, Delete)
// Table rendering from source
<TableRow>
  <TableCell>
    <IconVariable /> {variable.name}
  </TableCell>
  <TableCell>{variable.value}</TableCell>
  <TableCell>
    <Chip
      color={variable.type === 'static' ? 'info' : 'secondary'}
      label={variable.type}
    />
  </TableCell>
  <TableCell>
    {moment(variable.updatedDate).format('MMMM Do, YYYY HH:mm:ss')}
  </TableCell>
  <TableCell>
    {moment(variable.createdDate).format('MMMM Do, YYYY HH:mm:ss')}
  </TableCell>
</TableRow>

Updating Variables

// Edit flow from source
const edit = (variable) => {
  const dialogProp = {
    type: 'EDIT',
    cancelButtonName: 'Cancel',
    confirmButtonName: 'Save',
    data: variable
  }
  setShowVariableDialog(true)
}

const updateVariable = async () => {
  const obj = {
    name: variableName,
    value: variableValue,
    type: variableType
  }
  const updateResp = await variablesApi.updateVariable(variable.id, obj)
  if (updateResp.data) {
    enqueueSnackbar({ message: 'Variable updated', variant: 'success' })
    refreshVariablesCache()  // Update autocomplete
  }
}
Updating a variable immediately affects all flows using it on their next execution.

Deleting Variables

// Deletion with confirmation
const deleteVariable = async (variable) => {
  const isConfirmed = await confirm({
    title: 'Delete',
    description: `Delete variable ${variable.name}?`,
    confirmButtonName: 'Delete',
    cancelButtonName: 'Cancel'
  })
  
  if (isConfirmed) {
    const deleteResp = await variablesApi.deleteVariable(variable.id)
    if (deleteResp.data) {
      enqueueSnackbar({ message: 'Variable deleted', variant: 'success' })
      refreshVariablesCache()
    }
  }
}
Be careful when deleting variables. Flows using deleted variables will fail with unresolved reference errors.

How to Use Variables Dialog

The Variables page includes a “How To Use” button:
<Button onClick={() => setShowHowToDialog(true)}>
  How To Use
</Button>

<HowToUseVariablesDialog
  show={showHowToDialog}
  onCancel={() => setShowHowToDialog(false)}
/>
This dialog explains:
  • Variable syntax: ${{variableName}}
  • Where variables can be used
  • Static vs Runtime differences
  • Common examples

Common Use Cases

1. Model Configuration

Manage model versions centrally:
// Variables
DEFAULT_MODEL = "gpt-3.5-turbo"
FAST_MODEL = "gpt-3.5-turbo"
SMART_MODEL = "gpt-4"
EMBEDDING_MODEL = "text-embedding-ada-002"

// In flows
ChatOpenAI.modelName = "${{DEFAULT_MODEL}}"
OpenAIEmbeddings.modelName = "${{EMBEDDING_MODEL}}"
To upgrade all flows to GPT-4, just update DEFAULT_MODEL.

2. Environment-Specific Configuration

// Development
API_TIMEOUT = "5000"
MAX_RETRIES = "3"
LOG_LEVEL = "debug"

// Production
API_TIMEOUT = "30000"
MAX_RETRIES = "5"
LOG_LEVEL = "error"

3. Prompt Engineering

// System prompts as variables
BASE_SYSTEM_PROMPT = "You are a helpful assistant."
TECHNICAL_PROMPT = "You are an expert software engineer."
CREATIVE_PROMPT = "You are a creative writer."

// Prompt components
GREETING = "Hello! How can I help you today?"
CLOSING = "Is there anything else I can assist with?"
ERROR_MESSAGE = "I apologize, but I encountered an error."

4. Business Logic

// Thresholds
CONFIDENCE_THRESHOLD = "0.8"
MAX_RESULTS = "10"
MIN_SCORE = "0.5"

// URLs
DOCS_URL = "https://docs.example.com"
SUPPORT_EMAIL = "[email protected]"
ESCALATION_WEBHOOK = "https://hooks.example.com/escalate"

5. Multi-Language Support

// English
WELCOME_MESSAGE = "Welcome!"
ERROR_MESSAGE = "Something went wrong."

// Spanish
WELCOME_MESSAGE = "¡Bienvenido!"
ERROR_MESSAGE = "Algo salió mal."

// Use in flows
systemMessage: "${{WELCOME_MESSAGE}} How can I help?"

Variables vs Credentials

AspectVariablesCredentials
PurposeConfigurationAuthentication
SecurityNot encryptedEncrypted
VisibilityValue visible in UIValue hidden
Use forPrompts, parametersAPI keys, passwords
Syntax${{VAR_NAME}}Selected from dropdown
ExampleModel name, temperatureOpenAI API key
Rule of thumb: If it’s secret (API keys, passwords), use Credentials. If it’s configuration (prompts, settings), use Variables.

Best Practices

Naming Conventions

  • Use UPPER_SNAKE_CASE for variable names
  • Be descriptive: DEFAULT_MODEL not DM
  • Include context: SUPPORT_EMAIL not EMAIL
  • Use prefixes for grouping: PROD_API_URL, DEV_API_URL

Organization

// Group related variables
// Model Configuration
DEFAULT_LLM_MODEL
DEFAULT_EMBEDDING_MODEL
DEFAULT_TEMPERATURE

// API Configuration
API_BASE_URL
API_TIMEOUT
API_RETRY_COUNT

// Business Logic
COMPANY_NAME
SUPPORT_EMAIL
MAX_QUERY_LENGTH

Documentation

Include a README or doc page listing all variables:
# Project Variables

## Required Variables
- `DEFAULT_MODEL`: LLM model name (e.g., "gpt-3.5-turbo")
- `COMPANY_NAME`: Company name for prompts

## Optional Variables
- `LOG_LEVEL`: Logging verbosity (default: "info")

Version Control

For runtime variables, maintain an .env.example:
# .env.example
OPENAI_BASE_URL=https://api.openai.com/v1
COMPANY_NAME=Your Company
SUPPORT_EMAIL=[email protected]

Pagination Support

The Variables page supports pagination:
// From source
const [currentPage, setCurrentPage] = useState(1)
const [pageLimit, setPageLimit] = useState(DEFAULT_ITEMS_PER_PAGE)  // 10
const [total, setTotal] = useState(0)

const onChange = (page, pageLimit) => {
  setCurrentPage(page)
  setPageLimit(pageLimit)
  refresh(page, pageLimit)
}

const refresh = (page, limit) => {
  const params = { page: page || currentPage, limit: limit || pageLimit }
  getAllVariables.request(params)
}

// Response structure
{
  data: Variable[],    // Current page
  total: number        // Total count
}

Troubleshooting

Variable Not Resolving

Check:
  1. Variable name matches exactly (case-sensitive)
  2. Syntax is correct: ${{NAME}} not {{NAME}} or ${NAME}
  3. Variable exists in the current workspace
  4. No typos in variable name

Runtime Variable Returns Empty

Possible causes:
  1. Environment variable not set in .env
  2. Flowise not restarted after .env change
  3. Docker container not using correct .env file
  4. Variable name in Flowise doesn’t match env var name
Solution:
# Check environment variable is set
echo $VARIABLE_NAME

# Restart Flowise
npm run start

# Or restart Docker container
docker-compose restart

Variable Value Not Updating in Flow

  1. Clear any browser cache
  2. Ensure flow is saved after variable update
  3. Check variable cache is refreshed (automatic in UI)
  4. Try re-selecting the flow

API Reference

List All Variables

GET /api/v1/variables?page=1&limit=10
Response:
{
  "data": [
    {
      "id": "var-uuid",
      "name": "DEFAULT_MODEL",
      "value": "gpt-3.5-turbo",
      "type": "static",
      "createdDate": "2024-03-04T10:00:00Z",
      "updatedDate": "2024-03-04T10:00:00Z"
    }
  ],
  "total": 25
}

Get Variable by ID

GET /api/v1/variables/:id

Create Variable

POST /api/v1/variables
Content-Type: application/json

{
  "name": "DEFAULT_MODEL",
  "value": "gpt-3.5-turbo",
  "type": "static"
}

Update Variable

PUT /api/v1/variables/:id
Content-Type: application/json

{
  "name": "DEFAULT_MODEL",
  "value": "gpt-4",
  "type": "static"
}

Delete Variable

DELETE /api/v1/variables/:id

Build docs developers (and LLMs) love