Skip to main content

Templates

Templates allows you to create dynamic instructions and first messages in your Voice Bot by utilizing variables and conditions. This enables you to personalize conversations, adapt responses based on user data or API results, and pass dynamic data to function parameters.

Use Cases

  • Personalize the bot’s instructions to the AI model.
  • Restructure output from APIs and provide personalized instructions or output based on the result.
  • Use variables in function parameters to pass data like phone numbers or IDs.

Variables

Variables are placeholders that are replaced with actual values during runtime. They are enclosed within double curly braces {{variableName}}.

First Message
Hello {{firstName}}, how can I assist you today?

In this configuration, the system will pull the actual value associated with {{firstName}} from a Phonebook or CRM system. Once substituted, the modified message will then be played back to the user.

Predefined variables

Variable NameDescription
{{name}}Full name of the caller, if available (e.g., John Doe)
{{firstName}}First name of the caller, if available (e.g., John)
{{lastName}}Last name of the caller, if available (e.g., Doe)
{{phoneNumber}}Phone number of the caller (e.g., +34613581608)
{{sessionId}}Unique ID of the voice bot session (e.g., 1727940545.3.0)
{{botId}}Bot ID that handles the voice session (e.g., n0bMV55kFGO5)
{{callId}}Unique Call ID (e.g., 1727940545.3)
{{flowIndex}}Call Flow Index (e.g., 0)
{{language}}Language (e.g., English)
{{languageCode}}Language Code (e.g., en-US)
Function Parameters
{
"type": "object",
"properties": {
"phoneNumber": {
"type": "string",
"value": "{{phoneNumber}}"
}
},
"required": [
"phoneNumber"
]
}

Conditions

Conditions allow you to control the flow of the template by including or excluding content based on whether certain conditions are met. This is useful for personalizing messages when specific data is available.

Syntax

{{#if condition}}
<!-- Content to display if condition is true -->
{{else}}
<!-- Content to display if condition is false -->
{{/if}}

Example

First message
{{#if firstName}}
Hi {{firstName}}, how can I help you ?
{{else}}
Hi, how can I help you ?
{{/if}}

In this example, if {{firstName}} is available, the bot greets the user by their first name. If not, it displays a generic greeting.

You can also extend conditions using else if to handle multiple cases.

Reply Instructions
{{#if response.weather.isRaining}}
Don't forget your umbrella today, {{firstName}}!
{{else if response.weather.isSunny}}
It's a sunny day, {{firstName}}! A great time to be outdoors.
{{else if response.weather.isCloudy}}
It might be a bit gloomy today, {{firstName}}. Stay cozy!
{{else}}
I'm not sure what the weather is like today, {{firstName}}. Stay prepared!
{{/if}}

Loops

Loops allow you to iterate over arrays or lists of data, such as results from an API call, and dynamically generate content based on each item.

Loops are useful when you need to display a list of items or process each item in a collection. For example, you might retrieve a list of transactions from an API, but you only want to pass specified fields of the response to the model.

Use Cases:

  • To include or exclude certain parts of the information from the API in the response.
  • To restructure output from your API before presenting it to the user or the model.

Syntax

{{#each array}}
<!-- Content to display for each item -->
{{/each}}

Example

Here are your recent transactions:
{{#each response.transactions}}
- {{date}}: {{description}} for ${{amount}}
{{/each}}