System modules
System modules are modules enabled across the whole JAICP. System modules can be imported as dependencies into all bots without prior declaration.
Common system modules
The cloud version of JAICP provides the zb-common
system module.
It contains a number of universal and frequently used script elements:
- Named patterns.
- Named entity dictionaries and converters.
- JavaScript functions and libraries.
- Ready-made script fragments.
You can view the contents of all system modules in the script editor. Their code is read-only.
How to use
To import a file from a system module to the script, use the require
tag in one of the script files:
require: offtopic/fallback.sc
module = sys.zb-common
Here,
zb-common
is the name of the system module.offtopic/fallback.sc
is the path to the imported file.
The system module name should be prepended with sys.
.
Custom system modules On-premise
If JAICP is installed in your own infrastructure, your employees can create system modules that will be available to all users of your installation.
There are two ways to add system modules:
- Add the repository settings to the configuration of the EditorBE component.
- Connect the modules from the host where the BotServer component is installed.
The recommended way is to connect repository modules to EditorBE. If a module with the same name is connected both ways, the one connected via a repository will be used.
Modules from remote repositories
-
Developers create a remote repository with a JAICP project that is going to be imported into other projects as a system module.
-
System administrators should add the repository settings to the overriding configuration of the EditorBE component, then restart the component:
system-projects: projects: # Default system projects… - url: https://gitlab.custom.com/custom-tags # Repository URL. project-id: custom-tags # Project ID. branch: main # Branch in the project repository, master by default. module: true # This flag indicates that this is a system module.
-
Users of your JAICP installation will be able to import files from the system module using
require
. The system module name corresponds to theproject-id
parameter value:require: patterns.sc module = sys.custom-module
Modules from a local directory
-
System administrators should add the directory path where system modules will be stored to the overriding configuration of the BotServer component:
bot: systemModulesFolder: /opt/sys-modules
-
Projects that will be imported to other projects as system modules should be placed in this directory:
└── opt └── sys-modules ├── custom-module │ └── src │ └── patterns.sc └── js-packages └── src ├── moment.min.js └── underscore.min.js
-
Users of your JAICP installation will be able to import files from the system module using
require
. The system module name corresponds to the name of the subdirectory insidebot.systemModulesFolder
:require: patterns.sc module = sys.custom-module