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
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. |
intentGroup intentGroup! | Declares a group of intents 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. |
video | Sends a video file. |
Action tags
Action tags execute complex and frequently repeated bot actions or script fragments.
Tag | Description |
---|---|
Confirmation | Makes the bot ask the user to confirm some action. |
Email | Sends a message to the specified email address. |
EndSession | Ends the current user session and clears all session data. |
GoogleSheets | Integrates the script with Google Sheets. This allows the bot to read data from spreadsheets or write data into them. |
HttpRequest | Sends an HTTP request. This allows the bot to receive data from an external resource and save it into variables. |
InputFile | Makes the bot ask the user to upload a file and save a link to it into a variable. |
InputNumber | Makes the bot ask the user to enter a number within the specified range and save it into a variable. |
InputPhoneNumber | Makes the bot ask the user to enter a phone number and save it into a variable. Only Russian phone numbers are supported. |
InputText | Makes the bot request arbitrary text from the user and save it into a variable. |
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 phone channel bots). |
TransferToOperator | Switches the dialog to an agent in a customer engagement platform (for text bots). |