JAICP DSL
JAICP DSL is a language used for developing bot scripts in JAICP. It provides a convenient format for describing the business logic under which the bot operates.
JAICP DSL is based on tags. Every tag has a name ending with a colon. Additionally, every tag can have:
- A 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).
JAICP 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.
Tag | Description |
---|---|
init |
Defines a block code which is executed only once, when the script is loading. Typically, this code initializes global variables and functions. |
patterns |
Declares named patterns used in the script. |
require |
This tag is used for importing files into the script. |
state |
Declares a state in which the dialog context can be. States can be nested into each other to an arbitrary depth. |
theme |
Declares 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
!
.
Tag | Description |
---|---|
q q! |
Declares a pattern by which the dialog can enter a state. |
intent intent! |
Declares an intent by which the dialog can enter a state. |
event event! |
Declares an event by which the dialog can enter a state. |
Reaction tags
Reaction tags define the reactions executed upon entering a state.
Tag | Description |
---|---|
a |
Sends a text reply. |
audio |
Sends an audio file. |
buttons |
Sends buttons used for making transitions to other states. |
go |
Executes 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. |
if elseif else |
These tags enable script branching: executing different reactions based depending on the defined conditions. |
image |
Sends an image. |
inlineButtons |
Sends 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. |
newSession |
Starts a new session. |
random |
Executes one randomly chosen reaction. |
script |
Executes JavaScript code. |
Custom tags
Custom tags execute complex or frequently repeated bot actions or script fragments.
Tag | Description |
---|---|
Email |
Sends a message to the specified email address. |
GoogleSheets |
Integrates the script with Google Sheets, which allows a bot to read data from spreadsheets or write data into spreadsheets from the script. |
HttpRequest |
Sends an HTTP request. With the help of this tag, your bot can receive data from an external resource and save data into variables. |
InputFile |
Allows receiving a file from the user: for example, an item photo or a file with legal data. |
Sms |
Sends an SMS message to the specified phone number (only Russian phone numbers are supported). |
TelegramPayment |
Sends a Telegram payment form. |
TransferCallToOperator |
Switches the call to an agent, for example, when the bot cannot solve the user request without human aid (for phone channel bots). |
TransferToOperator |
Switches the dialog to an agent in a customer engagement platform (for text bots). |
In addition to using ready-made custom tags, you can also create your own.