Skip to main content

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.
tip
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.
tip
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.
tip
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

  1. Developers create a remote repository with a JAICP project that is going to be imported into other projects as a system module.

  2. System administrators should add the repository settings to the overriding configuration of the EditorBE component, then restart the component:

    configs/hosts/{env_name}/editorbe/application-override.yml
    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.
  3. Users of your JAICP installation will be able to import files from the system module using require. The system module name corresponds to the project-id parameter value:

    require: patterns.sc
    module = sys.custom-module

Modules from a local directory

  1. System administrators should add the directory path where system modules will be stored to the overriding configuration of the BotServer component:

    configs/hosts/{env_name}/botserver/application-override.yml
    bot:
    systemModulesFolder: /opt/sys-modules
  2. 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
  3. 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 inside bot.systemModulesFolder:

    require: patterns.sc
    module = sys.custom-module