Variables

Personalize assistant messages with dynamic and default variables

Overview

Use dynamic variables in the system prompt or any message in the dashboard with double curly braces (e.g., {{name}}).

To set values, make a phone call request through the API and set assistantOverrides. You cannot set variable values directly in the dashboard.

For example, set the assistant’s first message to “Hello, {{name}}!” and assign name to John by passing assistantOverrides with variableValues:

1{
2 "variableValues": {
3 "name": "John"
4 }
5}

Using dynamic variables in a phone call

1

Prepare Your Request

Create a JSON payload with these key-value pairs:

  • assistantId: Replace "your-assistant-id" with your assistant’s actual ID.
  • assistantOverride: Customize your assistant’s behavior.
    • variableValues: Include dynamic variables in the format { "variableName": "variableValue" }. Example: { "name": "John" }.
  • customer: Represent the call recipient.
    • number: Replace "+1xxxxxxxxxx" with the recipient’s phone number (E.164 format).
  • phoneNumberId: Replace "your-phone-id" with your registered phone number’s ID. Find it on the Phone number page.
2

Send the Request

Send the JSON payload to the /call/phone endpoint using your preferred method (e.g., HTTP POST request).

1{
2 "assistantId": "your-assistant-id",
3 "assistantOverrides": {
4 "variableValues": {
5 "name": "John"
6 }
7 },
8 "customer": {
9 "number": "+1xxxxxxxxxx"
10 },
11 "phoneNumberId": "your-phone-id"
12}

Ensure {{variableName}} is included in all prompts where needed.

Default Variables

These variables are automatically filled based on the current (UTC) time, so you don’t need to set them manually in variableValues:

VariableDescriptionExample
{{now}}Current date and time (UTC). For other timezones, use the LiquidJS date filter — see Advanced date and time usage below.Jan 1, 2024 12:00 PM
{{date}}Current date (UTC)Jan 1, 2024
{{time}}Current time (UTC)12:00 PM
{{month}}Current month (UTC)January
{{day}}Current day of month (UTC)1
{{year}}Current year (UTC)2024
{{customer.number}}The customer’s phone number (caller-ID for inbound calls, destination for outbound calls).+1xxxxxxxxxx
{{customer.X}}Any other customer property you set when creating the call.
{{phoneNumber.number}}The Vapi phone number that received the inbound call or placed the outbound call.+1xxxxxxxxxx
{{phoneNumber.name}}The display name you set on this phone number in the dashboard.Main Support Line
{{call.id}}The unique Vapi-generated ID for this call. Useful for correlating with your own logs, support tickets, or webhooks.5fe26c8e-...
{{call.type}}The kind of call this is. Useful for branching prompt behavior between channels.inboundPhoneCall / outboundPhoneCall / webCall
{{transport.callSid}}The provider-side call session ID (e.g. Twilio’s CallSid). Useful for BYOT customers correlating with their own provider logs.CA1234...
{{transport.conversationType}}Whether the conversation is over chat or voice.chat
{{transport.X}}Any other transport-related property.

To pass these values between tool calls within an assistant (rather than templating them into prompts), see Static variables and aliases. That page documents the trust tiers for these variables — which are signaling-derived and safe to use as a security boundary in tool calls, vs. conversation-derived ones that are not — and shows how to inject them into tool calls deterministically, without LLM mediation.

Advanced date and time usage

You can use advanced date and time formatting in any prompt or message that supports dynamic variables in the dashboard or API. We use LiquidJS for formatting - see their docs for details.

Format a date or time using the LiquidJS date filter:

1{{"now" | date: "%A, %B %d, %Y, %I:%M %p", "America/Los_Angeles"}}

Outputs: Monday, January 01, 2024, 03:45 PM

Examples:

  • 24-hour time:
    1{{"now" | date: "%H:%M", "Europe/London"}}
    17:30
  • Day of week:
    1{{"now" | date: "%A"}}
    Tuesday
  • With customer number:
    1Hello, your number is {{customer.number}} and the time is {{"now" | date: "%I:%M %p", "America/New_York"}}

Common formats:

Format StringOutputDescription
%Y-%m-%d2024-01-01Year-Month-Day
%I:%M %p03:45 PMHour:Minute AM/PM
%H:%M15:4524-hour time
%AMondayDay of week
%b %d, %YJan 01, 2024Abbrev. Month Day

Using dynamic variables in the dashboard

To use dynamic variables in the dashboard, include them in your prompts or messages using double curly braces. For example:

1Hello, {{name}}!

When you start a call, you must provide a value for each variable (like name) in the call configuration or via the API/SDK.

Always use double curly braces ({{variableName}}) to reference dynamic variables in your prompts and messages.

Setting assistant prompt using conversation type

Using the transport.conversationType variable in your assistant’s system prompt, you can modify how it behaves in chats or calls:

1[Identity]
2You are a helpful assistant, talking with a customer via {{transport.conversationType}}.
3
4[Response Guidelines]
5{% if transport.conversationType == "chat" -%}
6- Format numbers naturally; eg, a US phone number could be +1 (555) 123-4567
7- Use Markdown formatting for lists (both unordered and ordered)
8{%- elsif transport.conversationType == "voice" -%}
9- Always spell numbers in words; eg, 256 should be 'two hundred and fifty six'
10- Only ask one question at a time
11- Never use Markdown format; write everything as if it is being said aloud
12{%- endif -%}

HIPAA and Zero Data Retention mode

When HIPAA mode or Zero Data Retention is enabled for your organization or assistant, Vapi does not store any call data, including variable values. This means:

  • Variable values passed via variableValues are processed during the call but not persisted after the call ends
  • Call logs, recordings, and transcriptions are not stored
  • Variables are only available in real-time during the active call session

This ensures compliance with privacy requirements while still allowing you to personalize conversations with dynamic variables.

For more information on enabling HIPAA compliance and understanding data retention policies, see the HIPAA Compliance documentation.