Variables enable dynamic content substitution throughout the Syllable platform. They allow you to create personalized, context-aware experiences by automatically replacing variable placeholders with actual values during runtime.

Variable Syntax

All variables in the Syllable platform use the double curly brace syntax:
{{ variable_name }}
Variable names can include letters (A–Z, a–z), numbers (0–9), underscores (_), and periods (.). No spaces or other symbols are allowed inside the variable name. Spaces around the variable name are ignored, so {{ x }} and {{x}} are equivalent. This standardized format ensures consistency across all platform components and makes variables easily identifiable in your content.

Variable Types

System Variables

System variables provide access to platform-managed data and session context:
  • {{ vars.session.id }} - Unique identifier for the current session
  • {{ vars.session.agent.name }} - Name of the current agent
  • {{ vars.session.datetime }} - Current timestamp, e.g. 2025-01-02 12:00
  • {{ vars.session.date }} - Current date, e.g. 2025-01-02
  • {{ vars.session.language }} - The current language code for the session, e.g. en-US

Custom Variables

Custom variables allow you to define your own dynamic content:
  • {{ vars.custom_field }} - User-defined variables stored in the vars namespace

Usage Examples

In Prompts

Variables can be used within prompt content to create dynamic, personalized instructions:
You are a helpful customer service agent for {{ vars.company }}.
The current location is {{ vars.location_info }}
The current date is {{ vars.session.date }}.

In Greeting Messages

Create dynamic greeting messages that adapt to different contexts:
Hello! Thank you for calling {{ vars.company }}. 
My name is {{ vars.session.agent.name }} and I'm here to help you today.

{{ vars.business_hours_message }}

In Tool Descriptions

Make tool descriptions more contextual and informative:
{
  "function": {
    "name": "schedule_appointment",
    "description": "Schedule an appointment for {{ vars.customer_name }} at {{ vars.location_name }}. Current time: {{ timestamp }}"
  }
}

In Tool Static Parameters

Use variables to set dynamic default values for tool parameters:
{
  "staticParameters": [
    {
      "name": "customer_id",
      "default": "{{ vars.account_id }}",
      "description": "Customer account identifier"
    },
    {
      "name": "session_context",
      "default": "{{ vars.session.id }} - {{ vars.session.language }}",
      "description": "Session tracking information"
    }
  ]
}

Best Practices

Variable Naming

  • Use descriptive, lowercase names with underscores for readability
  • Prefix custom variables with vars. for clarity
  • Avoid spaces and special characters in variable names
Good examples:
  • {{ vars.customer_name }}
  • {{ order_number }}
Avoid:
  • {{ Customer Name }} (spaces)
  • {{ vars.customer-name }} (hyphens)
  • {{ CUSTOMER_ID }} (all caps)

Error Handling

Variables that cannot be resolved will typically:
  • Be replaced with blank values (e.g., Welcome, {{ unknown_var }}! becomes Welcome, !)
  • Not break the overall functionality
Always test your variable usage to ensure proper resolution.

Security Considerations

  • Never expose sensitive information through variables
  • Validate custom variable values before use
  • Be cautious when using variables in tool parameters that make external API calls

Common Use Cases

  • Multi-language Support
  • Time-based Messaging
  • Personalization

Dynamic Tool Configuration

{
  "staticParameters": [
    {
      "name": "order_id",
      "default": "{{ vars.order_id }}",
      "description": "Order ID"
    }
  ]
}

Troubleshooting

Variable Not Resolving

If a variable is not replaced or replaced with a blank string instead of its expected value:
  1. Check spelling - Variable names are case-sensitive
  2. Verify scope - Ensure the variable is available in the current context, for example a prompt can only reference variables that are available at the start of the session
  3. Check syntax - Confirm you’re using double curly braces {{ }}
  4. Validate data source - For custom variables, ensure the data source is properly configured

Migration from Legacy Formats

If you’re updating from older variable substitution formats, here are the conversions:
Legacy FormatNew Format
{variable}{{ variable }}
${variable}{{ variable }}
The recommended {{ variable }} syntax works exactly the same as the ${variable} syntax: if we the variable doesn’t exist, it defaults to an empty string. The {variable} syntax has slightly different behavior: if the variable doesn’t exist, the {variable} placeholder remains in the text as-is.
  • Prompts - Learn how to use variables in prompt content
  • Tools - Discover variable usage in tool configuration
  • Messages - Implement variables in greeting messages
  • Agents - Configure agent-level variable settings