Skip to main content

Script files

tip
Script files are the main files that define the bot operation logic. They have the .sc extension.

main.sc or entryPoint.sc is the main file of the chatbot script from which the script starts to load. The file must be located in the src folder that may also contain files with additional scripts, .csv dictionaries and .js scripts.

The script file includes: subject, state list, patterns, loaded files and responses. Other scripts and JS files can be loaded at the start of the script via the require tag.

require: scenarios/*.sc
require: scripts/functions.js

A chatbot script is written in the JAICP DSL language. JAICP DSL (Domain Specific Language) is the language used to define chatbot operation logic. It provides a user friendly format you can use to describe a finite state automation as the basis for your chatbot.

File structure

A chatbot script is defined in a text file with a tree structure. This means some elements are nested in others. These elements are states of the system it can switch to in the course of a conversation. E.g. a greeting or a number processing state.

Generic states include more specific states. For example, a loan application processing state can include a loan type question state.

tip
The nested level depends on the indent, like in the python and yaml language.

The greater is the indent (and the further to the right the element is), the higher is its nested level, the more parent states it has, and the longer is its name.

Let’s look at a sample script snippet:

theme: /BankTheme

state: Loan
q!: * loan* *
a: How can I help you?

state: TakeLoan
q: * ~get a loan* *
a: What kind of a loan would you like?

state: LoanTypes
q: * (car*|~mortgage|person*) *
go!: /FillTheLoanForm

State path depending on the nested level:

StateFull path
Loan/BankTheme/Loan
TakeLoan/BankTheme/Loan/TakeLoan
LoanTypes/BankTheme/Loan/TakeLoan/LoanTypes

Script file example

patterns:
$hello = (greetings|hi|hello|aloha|good (day|evening))

theme: /

state: Hello
q!: $hello *
a: Hello!
go!: /Can I Help You?

state: Can I Help You?
a: Can I help you?

state: Yes
q!: * { (*can you|*can you) * help me } *
q: * [I think] (yes|*can you|*can you|I hope|it would be) *
a: What would you like?

state: No
q: * [yes] [already] (nothing|not needed|not necessary) [thank you] *
a: Good. I will be glad to help you next time!