Skip to main content
Variables and expressions enable dynamic, reusable chatflows by injecting runtime values into your nodes. This guide covers global variables, node references, and expression syntax.

Overview

Flowise supports three types of dynamic values:
  1. Global Variables: Reusable values defined once, used everywhere
  2. Node References: Output from one node used as input to another
  3. Runtime Variables: User input and system-provided values

Global Variables

Global variables let you define values once and reference them across chatflows.

Creating Variables

1

Navigate to Variables

Click Variables in the main navigation to open the variables management page.
2

Add New Variable

Click Add Variable to create a new variable:
  • Name: Unique identifier (e.g., apiKey, personality, companyName)
  • Type: Static or Runtime
  • Value: The variable’s value
3

Configure Variable Type

Values stored directly in Flowise:
Name: companyName
Type: Static
Value: Acme Corporation
Use for:
  • Company information
  • Prompt templates
  • Configuration values
  • Non-sensitive constants
Never store sensitive values (API keys, passwords) as Static variables. Always use Runtime variables with environment variables.

Using Variables in Nodes

Reference variables in any text field using the $vars syntax:
Use double curly braces in text fields:
You are a {{$vars.personality}} AI assistant representing {{$vars.companyName}}.

Your role is to help customers with {{$vars.supportScope}}.
At runtime, Flowise replaces these with actual values:
You are a friendly and professional AI assistant representing Acme Corporation.

Your role is to help customers with product questions and troubleshooting.

Variable Syntax Reference

SyntaxDescriptionExample
{{$vars.name}}In text fields (prompts, messages)Hello {{$vars.userName}}
$vars.nameIn code (custom tools, functions)const key = $vars.apiKey
$vars.<name>Dot notation for variable access$vars.config.timeout

Node References

Connect nodes by referencing outputs in other node inputs.

Understanding Node Data Flow

When you connect nodes visually, Flowise generates reference expressions: The connection creates this reference:
{{chatOpenAI_0.data.instance}}

Reference Syntax

Access the node’s output instance:
{{nodeId.data.instance}}
Example:
// Reference ChatOpenAI model in Conversation Chain
{{chatOpenAI_0.data.instance}}

// Reference vector store in Retrieval QA Chain
{{pinecone_0.data.instance}}

// Reference tool in Agent
{{calculator_0.data.instance}}
Visual connections automatically create these references. You rarely need to write them manually.
Access specific data from node configuration:
{{nodeId.data.inputs.parameterName}}
Example:
// Get the model name from ChatOpenAI node
{{chatOpenAI_0.data.inputs.modelName}}
// Result: "gpt-4"

// Get prompt template from Prompt node
{{promptTemplate_0.data.inputs.template}}
// Result: "What is a good name for {product}?"
When a node accepts multiple inputs (e.g., tools for agents):
[
  "{{calculator_0.data.instance}}",
  "{{serpAPI_0.data.instance}}",
  "{{weather_0.data.instance}}"
]
Flowise automatically manages list inputs when you connect multiple nodes to a single anchor.

Runtime Variables

Variables provided automatically during execution.

User Input Variables

The user’s current message:
{{question}}
Example in Prompt:
User Question: {{question}}

Please provide a detailed answer based on the following context...
Example in Custom Function:
const userInput = $question  // Direct access in code
const processed = userInput.toLowerCase().trim()
return processed

Override Variables via API

Dynamically set variable values when calling the prediction API:
1

Define Variables in Flowise

Create variables as usual (e.g., userName, language, context).
2

Reference in Chatflow

Use variables in your nodes:
Hello {{$vars.userName}}! I'll respond in {{$vars.language}}.
3

Override via API

Send custom values in the API request:
const response = await fetch('https://flowise.com/api/v1/prediction/flowId', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    question: "What's the weather?",
    overrideConfig: {
      vars: {
        userName: "Alice",
        language: "Spanish",
        context: "weather_app"
      }
    }
  })
})
4

Result

The chatflow uses overridden values:
Hello Alice! I'll respond in Spanish.
Beyond variables, you can override other settings:
{
  "question": "User input",
  "overrideConfig": {
    // Variable overrides
    "vars": {
      "customVar": "value"
    },
    
    // Session management
    "sessionId": "user-123",
    
    // Model parameters
    "temperature": 0.3,
    "maxTokens": 1000,
    
    // RAG settings
    "returnSourceDocuments": true,
    "topK": 5,
    
    // Streaming
    "streaming": true
  }
}

Advanced Patterns

Conditional Logic with Variables

Use variables in conditional expressions (requires custom code nodes):
// In Custom Function node
const userTier = $vars.userTier  // "free", "pro", "enterprise"
const question = $question

if (userTier === "free") {
  return "Upgrade to Pro for this feature!"
} else if (userTier === "pro") {
  // Limited functionality
  return await basicAnalysis(question)
} else {
  // Full functionality
  return await advancedAnalysis(question)
}

Multi-Environment Configuration

Use variables for environment-specific settings:
.env.development:
OPENAI_MODEL=gpt-3.5-turbo
VECTOR_STORE_URL=http://localhost:6333
DEBUG_MODE=true
Variables:
defaultModel: Runtime -> OPENAI_MODEL
vectorStoreUrl: Runtime -> VECTOR_STORE_URL
debugMode: Runtime -> DEBUG_MODE

Templated System Messages

Create reusable personality templates:
You are {{$vars.botPersonality}}, an AI assistant for {{$vars.companyName}}.

Your expertise: {{$vars.expertiseArea}}

Tone: {{$vars.communicationTone}}

Constraints:
- {{$vars.constraint1}}
- {{$vars.constraint2}}

Current context: {{$vars.contextInfo}}
Set different values per deployment or user segment.

Dynamic Prompt Templates

Build prompts from variable components:
1

Define Prompt Parts as Variables

Variables:
  - promptPrefix: "You are a helpful assistant."
  - taskDescription: "Answer questions accurately."
  - outputFormat: "Provide answers in JSON format."
  - constraints: "Keep responses under 100 words."
2

Compose in Prompt Template

{{$vars.promptPrefix}}

Task: {{$vars.taskDescription}}

Format: {{$vars.outputFormat}}

Constraints: {{$vars.constraints}}

Question: {{question}}
3

Modify Behavior

Change variables to alter chatflow behavior without editing flows:
  • A/B test different prompts
  • Personalize per user segment
  • Adjust based on time/context

Expression Syntax Summary

Use in any text input field (prompts, messages, JSON strings):
{{expression}}
Examples:
{{$vars.variableName}}           # Global variable
{{nodeId.data.instance}}          # Node reference
{{question}}                      # User input
{{chat_history}}                  # Conversation history
{{nodeId.data.inputs.param}}     # Node configuration value
Use in custom code (tools, functions, loaders):
$expression
Examples:
$vars.variableName          // Global variable
$question                   // User input
$sessionId                  // Session ID
$input                      // Tool input parameter
$credentials.apiKey         // Credential value
Use in JSON parameter fields:
{
  "key": "{{expression}}"
}
Note: Always use strings in JSON, even for numbers:
{
  "temperature": "{{$vars.temp}}",  // ✅ String
  "temperature": {{$vars.temp}}     // ❌ Invalid JSON
}

Best Practices

  • Use camelCase: apiKey, userName, defaultModel
  • Be descriptive: openaiApiKey not key1
  • Prefix by category: llm_model, llm_temperature, db_connectionString
  • Avoid special characters (stick to letters, numbers, underscore)
  • Never store secrets as Static variables
  • Use Runtime variables for all sensitive data
  • Validate user input in custom functions
  • Sanitize variables used in SQL or external APIs
  • Review variable visibility (can users see them?)
  • Document variables with clear names
  • Group related variables (e.g., email_*, api_*)
  • Delete unused variables regularly
  • Export/import variables with chatflows for portability
  • Maintain a variable registry for team reference
  • Cache runtime variable lookups when possible
  • Avoid complex expressions in hot paths
  • Use static variables for constants (faster lookup)
  • Minimize API override vars (smaller payloads)

Common Use Cases

// Different configs per tenant
System Message:
You are an AI assistant for {{$vars.tenantName}}.

Branding: {{$vars.tenantBranding}}
Features: {{$vars.enabledFeatures}}

// Override via API per tenant
overrideConfig: {
  vars: {
    tenantName: "Acme Corp",
    tenantBranding: "professional",
    enabledFeatures: "analytics,reports"
  }
}
// Support multiple languages
Variables:
  - greeting_en: "Hello! How can I help you?"
  - greeting_es: "¡Hola! ¿Cómo puedo ayudarte?"
  - greeting_fr: "Bonjour! Comment puis-je vous aider?"

System Message:
{{$vars.greeting_{{$vars.userLanguage}}}}

// Or use override:
overrideConfig: {
  vars: {
    userLanguage: "es"
  }
}
// Test different prompts
System Message:
{{$vars.promptVariant_{{$vars.abTestGroup}}}}

Variables:
  - promptVariant_A: "Friendly assistant version"
  - promptVariant_B: "Professional expert version"
  - promptVariant_C: "Concise advisor version"

// Assign users to groups
overrideConfig: {
  vars: {
    abTestGroup: "B"  // Randomly assigned per user
  }
}

Troubleshooting

Symptoms: Seeing {{$vars.name}} literally in outputCauses:
  • Variable doesn’t exist
  • Typo in variable name
  • Wrong syntax (missing $ or {{}})
Solutions:
  1. Check variable exists in Variables page
  2. Verify exact name (case-sensitive)
  3. Use correct syntax: {{$vars.name}} in text, $vars.name in code
  4. For runtime variables, ensure .env file is loaded
Symptoms: Empty or null values when referencing nodesCauses:
  • Node not connected visually
  • Wrong node ID
  • Node hasn’t executed yet
Solutions:
  1. Use visual connections instead of manual references
  2. Check node ID in browser console (inspect node data)
  3. Ensure execution order (parent nodes execute first)

Next Steps

API Reference

Learn about overrideConfig and API usage

Custom Tools

Build custom tools using variables

Deployment

Environment variables in production

Security

Secure variable management

Build docs developers (and LLMs) love