Skip to Content
Enterprise GuidesVariables & Dynamic Content

Variables and Dynamic Content

This guide explains how to use variables in PromptOwl  to create dynamic, reusable prompts that adapt to different contexts and inputs.


Table of Contents

  1. Understanding Variables
  2. Variable Syntax
  3. System Variables
  4. Custom Variables
  5. Artifact and Folder Variables
  6. Block Output Variables
  7. Question-Based Variables
  8. Memory Variables
  9. Variable Resolution
  10. Best Practices
  11. Troubleshooting

Understanding Variables

Variables allow you to insert dynamic content into your prompts at runtime.

Why Use Variables?

BenefitExample
ReusabilitySame prompt, different company names
PersonalizationInclude user-specific context
Data IntegrationPull in artifact content
Workflow ChainingPass output between blocks

Variable Types Overview

TypeSourceExample
SystemBuilt-in, automatic\{memory\}, \{last_message\}
CustomUser-defined\{company_name\}, \{product\}
ArtifactData Room content\{context\} → artifact content
Block OutputPrevious block\{output_analysis\}
QuestionUser input\{user_goal\}

Variable Syntax

Basic Format

Variables use curly braces: \{variable_name\}

Examples:

Hello `{user_name}`, welcome to `{company_name}`! Based on the following context: `{context}` Please analyze and respond.

Naming Rules

RuleValidInvalid
Alphanumeric\{user_name\}\{user-name\}
Underscores OK\{company_info\}\{company info\}
No spaces\{productDetails\}\{product details\}
Case sensitive\{Name\}\{name\}-

Where Variables Work

LocationVariables Supported
System contextYes
Block instructionsYes
Human messagesYes
Variation textYes

System Variables

PromptOwl provides three built-in system variables automatically available at runtime.

\{memory\}

Contains user memories if memory is enabled.

What It Contains:

  • All user memories as formatted text
  • Categorized by type (Preferences, Personal, etc.)
  • Injected automatically when memory is enabled

Example Usage:

Consider the following about the user: `{memory}` Now respond to their question.

\{last_message\}

Contains the most recent message in the conversation.

What It Contains:

  • Content of the last user or assistant message
  • Useful for follow-up processing

Example Usage:

The user just said: `{last_message}` Provide a follow-up question based on this.

\{chat_history\}

Contains the full conversation history.

What It Contains:

  • All messages formatted with roles
  • User and assistant messages included
  • Chronological order

Example Usage:

Based on this conversation: `{chat_history}` Summarize the key points discussed.

System Variable Availability

VariableSimple PromptSequentialSupervisor
\{memory\}YesYesYes
\{last_message\}YesYesYes
\{chat_history\}YesYesYes

Custom Variables

Define your own variables for dynamic content.

Creating Custom Variables

  1. Open prompt for editing
  2. Find the Variables section
  3. Click Add Variable
  4. Enter variable name and value
  5. Use \{variable_name\} in your prompt

Variable Manager Interface

ElementDescription
Variable nameThe key used in \{name\} syntax
Variable valueContent to be inserted
Import buttonImport from artifacts/folders
Clear buttonRemove the value

Example: Company Context

Variables:

company_name: Acme Corporation industry: Software Development tone: Professional but friendly

Prompt:

You are a customer service representative for `{company_name}`, a `{industry}` company. Respond in a `{tone}` manner.

Resolved:

You are a customer service representative for Acme Corporation, a Software Development company. Respond in a Professional but friendly manner.

Static vs Dynamic Variables

TypeWhen ResolvedUse Case
Static (text)At prompt saveFixed values
Dynamic (artifact)At runtimeChanging content

Artifact and Folder Variables

Import content from your Data Room into prompts.

Importing an Artifact

  1. In Variables section, click Import
  2. Select Artifact tab
  3. Choose the artifact to import
  4. Assign a variable name
  5. Artifact content becomes the variable value

Importing a Folder

For RAG (retrieval) rather than direct injection:

  1. In Variables section, click Import
  2. Select Folder tab
  3. Choose the folder
  4. Folder becomes available for AI retrieval

How Artifact Variables Work

Storage Format:

context: artifact-60a7f5c3d8e9f12b4c5d6e7f

At Runtime:

  1. System detects artifact- prefix
  2. Fetches artifact content from database
  3. Replaces variable with actual content
  4. Content escaped to prevent injection

Artifact vs Folder Import

Import TypeBehaviorBest For
ArtifactEntire content injectedSmall, specific documents
FolderAI searches and retrievesLarge knowledge bases

Content Escaping

Artifact content is automatically escaped:

  • \{ becomes \{\{
  • \} becomes \}\}

This prevents accidental variable injection from artifact content.


Block Output Variables

Pass outputs between blocks in sequential prompts.

How It Works

In a sequential prompt:

  1. Block 1 generates output
  2. Output stored as \{output_block1id\}
  3. Block 2 can reference this output
  4. Chain continues for all blocks

Automatic Block Output Names

BlockOutput Variable
Block 1\{output_abc123\}
Block 2\{output_def456\}
Block 3\{output_ghi789\}

The block ID becomes part of the variable name.

Using Block Outputs

In Human Message field:

{output_previousBlockId}

In Block Instructions:

Based on the analysis: `{output_analysis_block}` Now provide recommendations.

Default Behavior

If you don’t specify a human message for a block:

  • System automatically uses previous block’s output
  • Format: \{output_previousBlockId\}

Example: Multi-Stage Analysis

Block 1 (Research):

Research the topic and provide key findings.

Output stored as: \{output_research\}

Block 2 (Analysis):

Human Message: Based on this research: `{output_research}` Instructions: Analyze the findings and identify patterns.

Output stored as: \{output_analysis\}

Block 3 (Recommendations):

Human Message: `{output_analysis}` Instructions: Provide actionable recommendations.

Question-Based Variables

Collect user input through questions to populate variables.

How Questions Work

  1. Define questions in prompt settings
  2. Questions shown to user at chat start
  3. Answers stored as variables
  4. Variables used in prompt

Creating Questions

  1. Open prompt settings
  2. Find Questions section
  3. Add question text
  4. Assign variable name
  5. Set visibility and requirements

Question Properties

PropertyDescription
TextThe question shown to user
VariableVariable name for the answer
VisibleWhether to show the question
RequiredMust be answered to proceed
Run FrequencyOnce or every time

Run Frequency Options

OptionBehavior
OnceAsk first time, cache answer
Every TimeAsk at each conversation start

Example: Personalized Assistant

Questions:

  1. “What is your name?” → \{user_name\}
  2. “What is your role?” → \{user_role\}
  3. “What are you working on?” → \{current_project\}

Prompt:

Hello `{user_name}`! As a `{user_role}` working on `{current_project}`, I'm here to help. What can I assist you with?

Memory Variables

Long-term context that persists across conversations.

How Memory Works

  1. User creates memories (persistent context)
  2. Memories categorized by type
  3. When memory enabled on prompt, \{memory\} variable populated
  4. AI uses memory context in responses

Memory Categories

CategoryExample Content
Preferences”I prefer concise answers”
Personal”My name is Sarah”
Professional”I work at Acme Corp”
Technical”I use Python 3.11”
Schedule”I’m in EST timezone”
Prompt SpecificContext for specific prompt

Enabling Memory

  1. Open prompt settings
  2. Find Memory toggle
  3. Enable memory
  4. \{memory\} now available in prompt

Using Memory in Prompts

Implicit Use: When memory is enabled, it’s automatically included in context.

Explicit Reference:

User preferences and context: `{memory}` Based on this information, respond appropriately.

Memory vs Question Variables

FeatureMemoryQuestions
PersistencePermanentPer-session (if “once”)
User controlUser managesDefined by prompt
ScopeAll prompts (if enabled)Single prompt

Variable Resolution

Understanding how variables are processed at runtime.

Resolution Order

  1. Custom variables defined on prompt
  2. Artifact/folder content fetched and inserted
  3. Question answers from user input
  4. System variables (memory, last_message, chat_history)
  5. Block outputs from previous blocks

Resolution Process

Prompt Template with `{variables}` Fetch artifact content (if artifact- prefix) Merge all variable sources String replacement: `{name}` → value Escape special characters Final prompt sent to AI

Handling Missing Variables

ScenarioBehavior
Variable undefinedReplaced with empty string
Artifact not foundEmpty string, error logged
Block output missingEmpty string, warning logged

Type Conversion

Value TypeConversion
StringUsed directly
NumberConverted to string
BooleanConverted to string
Object/ArrayJSON stringified
null/undefinedEmpty string

Best Practices

Variable Naming

Do:

  • Use descriptive names: \{company_overview\}
  • Use underscores for readability: \{user_profile_summary\}
  • Be consistent across prompts

Don’t:

  • Use single letters: \{c\}
  • Use reserved names: \{system\}, \{prompt\}
  • Mix naming conventions

Variable Organization

Group Related Variables:

# Context Variables company_name industry target_audience # Style Variables tone format length

Artifact Variables

Do:

  • Use for stable reference content
  • Keep artifact content focused
  • Update artifacts when info changes

Don’t:

  • Import very large artifacts inline
  • Use for frequently changing data
  • Forget about sync status

Sequential Workflow Variables

Do:

  • Name blocks descriptively (helps identify outputs)
  • Document expected outputs
  • Handle missing outputs gracefully

Don’t:

  • Create circular references
  • Skip documenting block purposes
  • Assume outputs will always exist

Security Considerations

Do:

  • Sanitize user input in questions
  • Be careful with artifact content
  • Test variable injection scenarios

Don’t:

  • Put sensitive data in variables
  • Trust unvalidated user input
  • Expose internal variable names

Troubleshooting

Variable Not Resolving

Symptoms: \{variable_name\} appears in output

Solutions:

  1. Check variable name spelling (case sensitive)
  2. Verify variable is defined
  3. Check variable has a value
  4. Confirm using correct syntax \{name\} not \{{name}\}

Artifact Content Empty

Symptoms: Variable resolves to nothing

Solutions:

  1. Check artifact exists in Data Room
  2. Verify artifact has content
  3. Check artifact is synced
  4. Confirm artifact ID is correct

Block Output Missing

Symptoms: Sequential block gets empty input

Solutions:

  1. Verify previous block executed
  2. Check block ID in variable name
  3. Review previous block for errors
  4. Check human message references correct block

Memory Not Appearing

Symptoms: \{memory\} is empty

Solutions:

  1. Verify memory is enabled on prompt
  2. Check user has created memories
  3. Confirm memories aren’t empty
  4. Test with explicit memory content

Question Answers Not Saved

Symptoms: Must re-answer questions

Solutions:

  1. Check run frequency setting
  2. Verify answer was submitted
  3. Check for validation errors
  4. Try clearing and re-answering

Unexpected Characters in Output

Symptoms: Extra \{\{ or \}\} in text

Solutions:

  1. This is intentional escaping
  2. Artifact content with braces gets escaped
  3. Review source content if problematic
  4. Consider alternative formatting

Variable Shows “undefined”

Symptoms: Literal “undefined” in output

Solutions:

  1. Variable value is JavaScript undefined
  2. Set explicit empty string instead
  3. Check variable initialization
  4. Review data source

Quick Reference

Variable Types Summary

TypeSyntaxSource
System\{memory\}Built-in
Custom\{company\}User-defined
Artifact\{context\}Data Room
Block Output\{output_id\}Previous block
Question\{answer\}User input

System Variables

VariableContent
\{memory\}User memories
\{last_message\}Most recent message
\{chat_history\}Full conversation

Common Patterns

Personalization:

Hello `{user_name}`, how can I help you today?

Context Injection:

Using this information: `{context}` Answer the following question.

Sequential Chaining:

Based on: {output_previousBlock} Now continue with the next step.

Variable Checklist

  • Variable names are descriptive
  • All variables have values defined
  • Artifact variables point to valid artifacts
  • Block outputs reference correct IDs
  • Questions configured with correct frequency
  • Memory enabled if using \{memory\}

Last updated on