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 API 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}}
.
Predefined variables
Variable Name | Description |
---|---|
{{name}} | Full name of the user, if available (e.g., John Doe) |
{{firstName}} | First name of the user, if available (e.g., John) |
{{lastName}} | Last name of the user, if available (e.g., Doe) |
{{email}} | Email of the user, if available (e.g., john.doe@example.com) |
{{channelId}} | Unique ID of the chat bot session (e.g., da02a2ee-8585-4f92-a4bd-ba8591fe) |
{{botId}} | Bot ID that handles the chat session (e.g., n0bMV55kFGO5) |
{{dateTime}} | The date and time at which the request was processed (e.g., 04/03/2025, 14:31:02) |
{{time}} | The time at which the request was processed (e.g., 14:31:02) |
{{date}} | The date at which the request was processed (e.g., 04/03/2025) |
{{dayOfWeek}} | The day of the week at which the request was processed (e.g., Thursday) |
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
Example
In this example, if {{name}}
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.
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
Example