Skip to main content

Tovie DSL

Tovie DSL is a language used for developing bot scripts in Tovie Platform. It provides a convenient format for describing the business logic under which the bot operates.

Tovie DSL is based on tags. Every tag has a name ending with a colon. Additionally, every tag can have:

  • value specified immediately after the name. Values directly determine the tag behavior, and most tags have them.
  • Parameters — key–value pairs separated from the name or value (if present) with two vertical bars. If there are several parameters, they are separated from each other with commas. Parameters modify the tag behavior.
  • Nested data specified on a separate line after the tag declaration and is indented. Nested data contains other tags.
tag1: value1
tag2: value2 || paramKey = "paramValue", booleanParam = true
The level of nesting is controlled by indentation, similarly to such languages as Python and YAML. Within the same script file, the number of spaces for each indentation level should be the same (usually it is 4).

Tovie DSL uses tags of the following types:

Declarative tags

Declarative tags describe the overall script structure: they define the states building up the bot business logic, determine the imported files, and execute code and pattern initialization.

initDefines a block code which is executed only once, when the script is loading. Typically, this code initializes global variables and functions.
patternsDeclares named patterns used in the script.
requireThis tag is used for importing files into the script.
stateDeclares a state in which the dialog context can be. States can be nested into each other to an arbitrary depth.
themeDeclares a theme. States can only exist within themes.

Trigger tags

Trigger tags determine the user actions and events which can switch the dialog context to some state. There are two types of all trigger tags: local and global tags.

  • Transitions by local tags can be made only from the nearest parent, sibling, or children states.
  • Transitions by global tags can be made from anywhere in the script. Their names end with !.
Declares a pattern by which the dialog can enter a state.
Declares an intent by which the dialog can enter a state.
Declares a group of intents by which the dialog can enter a state.
Declares an event by which the dialog can enter a state.

Reaction tags

Reaction tags define the reactions executed upon entering a state.

aSends a text reply.
audioSends an audio file.
buttonsSends buttons used for making transitions to other states.
goExecutes a deferred transition to another state. Target state reactions are not executed, but the next request is processed in the context of this state.
go!Executes an immediate transition to another state.
These tags enable script branching: executing different reactions based depending on the defined conditions.
imageSends an image.
inlineButtonsSends inline buttons.
Clicking an inline button can either send some data or make the user follow a link. Inline buttons are displayed inside the dialog as chatbot responses rather than underneath it.
randomExecutes one randomly chosen reaction.
scriptExecutes JavaScript code.
timeoutSets an automatic transition to another state if there is no input from the user.
videoSends a video file.
newSessionDeprecated Creates a new session.

Action tags

Action tags execute complex and frequently repeated bot actions or script fragments.

ConfirmationMakes the bot ask the user to confirm some action.
EmailSends a message to the specified email address.
EndSessionEnds the current user session and clears all session data.
HttpRequestSends an HTTP request. This allows the bot to receive data from an external resource and save it into variables.
InputFileMakes the bot ask the user to upload a file and save a link to it into a variable.
InputNumberMakes the bot ask the user to enter a number within the specified range and save it into a variable.
InputTextMakes the bot request arbitrary text from the user and save it into a variable.
SmsSends an SMS message to the specified phone number.
TelegramPaymentSends a Telegram payment form.
TransferCallToOperatorSwitches the call to an agent (for phone channel bots).
TransferToOperatorSwitches the dialog to an agent in a customer engagement platform (for text bots).
In addition to using built-in action tags, you can also create your own.