Skip to main content

Overview

Dynamic variables let you write one reusable agent prompt and fill in customer-specific details when a call or chat starts. Use variables in prompts with double curly braces:
Kejue renders the variables before the agent starts speaking. For live updates during an active call, use Mid-Call Context Injection instead.

Where variables work

You can use dynamic variables in:
  • Voice agent system prompts
  • Voice agent first messages
  • Per-call prompt overrides
  • Chat agent prompts
You can pass custom values from the dashboard’s Context Variables / Request Data fields, or through the API using the context object.
Voice prompts and first messages support the full nested contact object, including custom contact metadata. Chat prompts currently support workspace variables and flat contact aliases such as contact_name, contact_first_name, contact_company, and contact_phone.

Syntax

You can chain defaults and transforms:

Built-in variables

Contact variables

Use the nested contact object for customer details:
{{customer_name}} is not a built-in automatic alias. Use {{contact.full_name}}, {{contact.first_name}}, or pass your own customer_name value in context.

Custom contact fields

Custom fields on a contact are stored in metadata and can be referenced from voice prompts and first messages with {{contact.metadata.<key>}}. For example, a contact with this metadata:
can be used in a prompt like this:
When contacts are imported from CSV or Excel, recognized columns such as phone, first_name, email, company, job_title, language, and tags are mapped to normal contact fields. Unrecognized columns are stored as contact metadata using the original column header as the key. For a CSV like:
the custom fields are available as:
Prefer simple metadata keys like policy_type, renewal_date, or account_manager when possible. They are easier to read in prompts and safer to reuse across imports and API-created contacts. Contact create, update, and bulk-create API requests can also set metadata directly:
Metadata keys are not automatically available as top-level variables. Use {{contact.metadata.policy_type}} for reusable contact data, or pass policy_type in per-call context if you want to reference it as {{policy_type}}.

Agent and persona variables

Date and time variables

Workspace variables

If your workspace has saved template variables, you can use them directly:
Workspace variables are useful for values that are shared across many agents, such as company names, product names, policies, disclaimers, or business hours.

Pass custom variables for one call

When creating a call, include a context object. Each key becomes available in the prompt.
Then reference those values in the prompt:

JavaScript example

Variable precedence

If the same variable name exists in multiple places, more specific values win:
  1. System date/time variables
  2. Workspace variables
  3. Persona data
  4. Contact data
  5. Conversation data
  6. Per-call context variables
Per-call context variables have the highest priority. Avoid custom keys named contact, persona, conversation, or memory unless you intentionally want to override those namespaces.

Best practices

  • Use {{contact.first_name|default:there}} instead of assuming every contact has a name.
  • Use clear, snake_case custom variable names such as policy_type, appointment_time, or case_reason.
  • Keep context values short and specific. Long background information belongs in memory, knowledge, or mid-call context injection.
  • Do not put secrets, API keys, or credentials in prompt variables.
  • For scheduled calls, pass all required per-call context when creating the call.

Troubleshooting