Agent variables and templates
A Wilma agent can put values into its texts: the instructions, the greeting, the lines it speaks, tool values and descriptions. A text with {{…}} is a Handlebars template. The agent fills it when a session starts.
A variable is a value that comes from outside the agent. The model does not invent it. When no value arrives, {{NAME}} becomes empty text, and the agent does not see that something is missing. Write the texts so that they also work without the value (see Conditions).
Declare the inputs of an agent
Declare the values that an agent expects in Agent → Settings → Variables: the name, the type, a description, and whether the value is optional.
- The editor suggests the declared names when you type
{{. It also suggests the built-in names of the channels that the agent uses. - A name that is not declared shows as a warning, because a call can still send it.
- Another agent that asks this agent ("Ask an agent") sees the declared names as its inputs.
Where values come from
| Source | How | Example |
|---|---|---|
| A PBX call | Set a dialplan variable with the VOICEBOT_ prefix. The PBX removes the prefix. | Set(VOICEBOT_ORDER_ID=123) gives {{ORDER_ID}} = 123 |
| Another agent ("Ask an agent") | Each input of the target agent is Automatic (the model fills it), Guided (the model fills it with your description), or Fixed (a template that you write, for example {{ORDER_ID}}). | Fixed TOPIC = {{#if VIP}}vip{{else}}regular{{/if}} billing |
| The API | options.variables of StartSession or StartTask. | "options": {"variables": {"ORDER_ID": "123"}} |
A dialplan sends every value as text. In a condition, the text false is false (see Conditions). A dialplan value is never a list or a number, so {{#each ITEMS}} over a dialplan value gives no text. Send a list or a number from the API or from another agent.
Built-in names
These names are always available. You do not declare them.
| Name | Value | Voice | Chat and assistant |
|---|---|---|---|
{{user.name}}, {{user.email}}, {{user.officePhone}} | The caller, when the PBX knows the value. The session user in chat. | yes | yes |
{{user.company}} | The company of the caller's contact, when the PBX knows it. | yes | — |
{{user.id}}, {{user.extension}}, {{user.mobilePhone}}, {{user.timeZone}} | The session user. | instructions and tools | yes |
{{call.id}}, {{call.dialedNumber}} | The PBX call, and the number that the caller dialed. | yes | — |
{{conversation.id}} | The chat conversation. | — | yes |
{{session.id}}, {{session.channel}} | The session. | yes | yes |
{{session.date}}, {{session.time}}, {{session.dateTime}}, {{session.dayOfWeek}}, {{session.timeZone}} | When the session started, in the agent's time zone: 2026-11-13, 14:05, 2026-11-13 14:05, Friday, Europe/Rome. | yes | yes |
{{agent.id}}, {{agent.version}} | The agent. | yes | yes |
The session date and time do not change during a session. The model receives the current time with each message, so do not use these names to tell the model the time of a long chat.
A declared variable never replaces a built-in name: an input called user does not change {{user.name}}.
Conditions
Use a condition to give a text for a missing value:
| Block or helper | Use |
|---|---|
{{#if X}}…{{else}}…{{/if}}, {{else if Y}} | Text when X has a value. Empty text, false (as text too), 0 and an empty list are false. |
{{#unless X}}…{{/unless}} | Text when X has no value. |
{{#if (eq TIER "gold")}} | eq is true when two values are the same text. |
{{#each ITEMS}}{{this}}{{/each}} | Repeats the text for each item of a list. |
{{uppercase X}}, {{lowercase X}}, {{trim X}} | Changes the text of a value. |
{{urlEncode X}}, {{jsonStringify X}} | Writes a value into a URL or a JSON body. |
When you type {{# the editor suggests the blocks. A block is inserted whole, for example {{#if }}{{else}}{{/if}}, with the cursor on the condition. Inside an open block, {{ suggests else, and {{/ suggests the closing tag.
Where templates apply
- Instructions, pipeline instructions, capability and tool descriptions.
- The voice greeting, tool start messages, wait messages and the goodbye lines of the time limits.
- Fixed and Guided tool values, and the inputs that an agent sends to another agent.
- Annotation values.
- Workflow step goals, pipeline instructions inside a workflow, and exit conditions.
The values are filled in once, when the session starts. A spoken line is translated first and filled in after, so a value is never translated.
Validation
When you save an agent, every template is checked. A template that is not valid Handlebars (for example {{NAME} or an open {{#if}} with no {{/if}}), or that uses an unknown helper, is refused. The error names the field. In the editor, the same problems show under the field.
A Fixed tool value that refers to a name with no value is not sent. The tool receives no field, not an empty one. A name inside {{#if}} or {{#each}} does not cause this.
Names from legacy voice and chat bots
The legacy bots used flat names. A Wilma agent uses these names instead:
| Legacy | Wilma agent |
|---|---|
{{name}}, {{firstName}}, {{lastName}} | {{user.name}} |
{{phoneNumber}} | {{user.officePhone}} |
{{email}} | {{user.email}} |
{{callId}} | {{call.id}} |
{{channelId}} | {{conversation.id}} |
{{sessionId}} | {{session.id}} |
{{botId}} | {{agent.id}} |
{{date}}, {{time}}, {{dateTime}}, {{dayOfWeek}} | {{session.date}}, {{session.time}}, {{session.dateTime}}, {{session.dayOfWeek}} |
Dialplan variables (VOICEBOT_*) keep their names. When the Wilma assistant migrates a legacy bot, it rewrites these names for you.