Skip to main content

Variable Inputs for AI Agents: Collect Information Before Chat

Abdul Samad avatar
Written by Abdul Samad
Updated this week

Overview

Variable Inputs enable AI agents to collect specific information from users before starting a conversation. By defining variables that users must complete, agents receive essential context upfront—eliminating repetitive questions and delivering personalized, relevant responses from the first message.

Learning Objectives:

  • Define variables using {{variable_name}} syntax in system prompts

  • Configure input types (text, dropdown, number, date) for each variable

  • Apply validation rules to ensure data quality

  • Design user-friendly input forms that streamline conversations

  • Implement advanced features like API-sourced dropdowns

Prerequisites

You'll Need:

  • An existing AI agent you own and can edit

  • Understanding of the information your agent needs before chatting

  • For API dropdowns: accessible endpoint that returns options in correct format

  • Clear use case for why pre-chat data collection improves agent performance


Define Variables in System Prompt

Add Variables to Agent Instructions

  1. Open agent edit interface

    • Navigate to the "Agents" icon

    • Find your agent in the list

    • Click three-dot menu (⋯) → Select "Edit Agent"

  2. Access Instructions or System Prompt

    • In agent edit interface, locate "Instructions" field

  3. Insert variables using double curly braces

    You are a support agent helping with {{product_name}} issues. The customer's account type is {{account_tier}} and they're using version {{version_number}}. Their primary use case is {{use_case}}.

  4. Use variables naturally in context

    • Reference variables where they make grammatical sense

    • Include multiple variables throughout prompt

    • Ensure each variable serves a clear purpose

Result: Variables are automatically detected by system and appear in Variable Inputs configuration tab.

Tip: Use descriptive names like {{project_name}} instead of {{pn}} for clarity.


Configure Variable Inputs Settings

Access Variable Configuration

  1. Navigate to Variable Inputs tab

    • In agent edit interface, find tabs across the top

    • Click "Variable Inputs" tab

    • Form appears with detected variables listed

  2. Configure each variable

    • Click on variable name (e.g., "product_name") to expand settings

    • Complete all configuration fields:

Setting

Purpose

Example

Display Name

Label users see

"Product Name"

Input Type

Field format

Text, Dropdown, Number, Date

Required

Mandatory field

Checkbox (checked = mandatory)

Default Value

Pre-populated info

"Premium Plan"

Description

Helper text

"Which product are you contacting us about?"

Validation Rules

Input constraints

Pattern, min/max, error message


Configure Input Types

Text Inputs

  1. Select "Text" in Input Type dropdown

  2. Recommended for: Free-form information like names, IDs, descriptions

  3. Enable pattern validation (optional)

    • Toggle "Pattern Validation" on

    • Enter regex pattern: ^[A-Z0-9]{5,10}$

    • Add custom error: "Please enter 5-10 uppercase letters and numbers"

Best for: Names, email addresses, project IDs, descriptions


Dropdown Inputs

  1. Select "Dropdown" in Input Type dropdown

  2. Choose option source:

    • Static Options: Manually entered list

    • API Source: Dynamic loading from endpoint

  3. Configure static options

    • Click "Add Option"

    • Enter Label (what users see): "Premium Support"

    • Enter Value (what's passed to agent): "premium"

    • Repeat for all options

    • Drag to reorder options

  4. Configure API source (advanced)

    • Toggle "Load from API"

    • Enter API Endpoint URL

    • Set Request Method: GET or POST

    • Map Label Field: Response field to show users (e.g., "display_name")

    • Map Value Field: Response field to pass to agent (e.g., "id")

    • Add Headers if authentication required

Best for: Product names, issue categories, account tiers, departments


Number Inputs

  1. Select "Number" in Input Type dropdown

  2. Set minimum and maximum values

    • Enter Min Value: 1

    • Enter Max Value: 100

  3. Set decimal places (optional)

    • Set precision (e.g., 2 decimal places)

Best for: Team size, budget amounts, quantity, percentages


Date Inputs

  1. Select "Date" in Input Type dropdown

  2. Configure date

    • Default value: Set a default value for this variable

Best for: Project deadlines, report date ranges, milestone dates


Set Validation Rules

Ensure Data Quality

  1. Mark required fields

    • Toggle "Required" on for mandatory variables

    • User cannot start chat without completing these

  2. Add custom error messages

    • In Description field, enter helpful guidance:

    • Example: "Please select a valid product from the list"

  3. Test validation logic

    • Make sure to save changes

    • Go to the "agents" icon in the left panel

    • Look for your agent and click "Use Agent"

    • Try your agent without required fields

    • Verify error messages display correctly

Result: Users cannot proceed with invalid or missing data.


User Experience

What End Users See

  1. Agent profile and description

    • Users see agent name, avatar, and description first

  2. Input form appears

    • Below description, form displays with configured fields

    • Fields appear in order you configured them

    • Required fields marked with asterisk (*)

    • Descriptions display as help text below each field

  3. Form submission

    • User completes all required fields

    • Clicks "Start Chat" or "Submit"

    • Form validates in real-time

  4. Conversation begins

    • Agent receives all variable values in system prompt

    • Agent immediately uses context in responses

    • No repetitive questions needed

Result: Streamlined experience with all context pre-loaded.


Best Practices

Writing Good Variable Names

  • Use clear, descriptive names: {{project_name}} instead of {{pn}}

  • Use underscores for multi-word: {{account_tier}} not {{accountTier}}

  • Stay consistent across all agents

Creating User-Friendly Forms

  • Keep required fields minimal - Only collect essential information

  • Provide clear descriptions - Explain why information is needed

  • Use appropriate input types - Match field type to data format

  • Group related variables - Configure in logical order

  • Set smart defaults - Pre-populate when possible to reduce user effort

System Prompt Integration

  • Reference variables naturally: "You're helping with {{product_name}} issues"

  • Use variables to create conditional instructions

  • Ensure variable substitution reads grammatically correctly

  • Test prompt with sample values


Example Use Cases

Customer Support Agent

Variables Collected:

  • {{account_id}} - Text input with pattern validation

  • {{issue_category}} - Dropdown: "Technical, Billing, Account"

  • {{urgency_level}} - Dropdown: "Low, Medium, High, Critical"

Agent Benefit: Immediately knows customer context and prioritization

Sales Assistant

Variables Collected:

  • {{industry}} - Dropdown from API (industry database)

  • {{company_size}} - Dropdown: "1-10, 11-50, 51-200, 200+"

  • {{current_tools}} - Text input (comma-separated list)

Agent Benefit: Provides tailored product recommendations based on company profile

Project Management Bot

Variables Collected:

  • {{project_name}} - Text input (required)

  • {{team_size}} - Number input (min: 1, max: 100)

  • {{timeline_date}} - Date input (cannot be past date)

Agent Benefit: Suggests appropriate methodologies and tools based on project scope

Analytics Assistant

Variables Collected:

  • {{data_source}} - Dropdown: "CRM, Database, Analytics Platform"

  • {{time_period}} - Text (date range format: "YYYY-MM-DD to YYYY-MM-DD")

  • {{metrics}} - Dropdown: "Revenue, Users, Conversion, All"

Agent Benefit: Immediately generates relevant reports with specified parameters


Troubleshooting

Variable Not Appearing in Form

Cause: Variable not properly formatted in system prompt

Solution:

  1. Verify variable uses correct format: {{variable_name}}

  2. Check that you didn't delete it from the prompt

  3. Ensure no spaces in variable name: {{product_name}} not {{product name}}

  4. Save agent settings and refresh page

Dropdown Options Not Loading

For Static Options:

  • Verify at least one option is added

  • Check that label and value are both populated

For API Source:

  • Ensure API endpoint is accessible (not blocked by CORS)

  • Verify API returns correct JSON format

  • Check label/value mappings match response structure

  • Add authentication headers if API requires them

Validation Rules Not Working

Cause: Incorrect rule configuration

Solution:

  1. Check required field toggle is enabled

  2. Verify pattern regex is valid

  3. Ensure number ranges are logical (min < max)

  4. Test with preview form if available

Form Layout Issues

Cause: Too many variables or poor ordering

Solution:

  • Reduce number of required fields

  • Reorder variables in more logical sequence

  • Group related fields together

  • Use clear descriptions to reduce confusion


Common Questions

Q: Can I add variables after creating the agent?
A: Yes. Edit agent → Update system prompt with new {{variables}} → Configure them in Variable Inputs tab.

Q: Can I make variables optional?
A: Yes. Toggle "Required" off for any variable. Users can skip optional fields.

Q: Can I change variable order after creation?
A: Yes. In Variable Inputs tab, drag variable rows to reorder. Order affects form display.

Q: Can I hide certain variables from end users?
A: No. All defined variables appear in the form. To hide data, use default values or connect datastores instead.

Q: Can variables have default values that users can override?
A: Yes. Enter default value in configuration. Users can accept it or change it.

Q: Can I use the same variable across multiple agents?
A: Yes, but each agent must define it in its own Variable Inputs tab. Variable scope is per-agent.

Q: How many variables can I add?
A: No hard limit, but forms with 6+ variables become cumbersome. Keep required fields under 5.

Q: Can I use variables in agent instructions AND system prompt?
A: Yes. Variables are replaced throughout the agent configuration wherever {{variable_name}} appears.

Did this answer your question?