Categories:
Plugin Manager
Description of Aura Bot plugin manager, module in charge of loading all the information from external libraries
Introduction
Plugin Manager is the aura-bot module in charge of loading all the dialogs libraries (from now on, libraries will be referred as plugins) to make them available to answer the users’ requests in a use case.
Plugins interface is the definition object that could be consumed by other modules. We can found dialogs and middlewares from external libraries to be imported in aura-bot.
The interface that handles the Plugin Manager for each aura-bot library is:
export interface Plugins {
middlewares?: Array<MiddlewareExecution<TurnContext>>;
dialogs: Dialog[];
}
Loading process
The following information is read during the loading process for each plugin (in case the plugin provides it):
configSchema: it contains joi schema of local libraries variable. Find more information in libraries configuration.dialogs: dialogs of the library to resolve the use case.middlewares: future use.
In the same event loop using architect to get each plugin, the first step will be to load the configSchema of the plugin and validate it. If there are no errors, the next step will be to load the dialogs and middlewares defined in the plugin.
If the schema validation process throws any error, the plugin will be stopped by the Plugin Manager and the process will go on loading the rest of the plugins. Errors will be gathered during the whole loading process and will be shown at once at the end.
Configuration delivery to dialogs and middlewares
Plugin Manager is in charge of preparing and delivering configuration of external dialogs and middlewares. By now, in this first approach, all variables will be passed to all loaded modules. In this point all variables can be easily filtered, if needed.
Regarding libraries configuration, each library/plugin may count on a @hapi/joi schema. If a library has one, then it will be validated with process.env, that contains all the environment variables from aura-bot and from every configured library merged during configuration process.
Further information is found in configuration basics.
If the plugin has no schema defined, the Plugin Manager will deliver all global configuration variables directly to the plugin, by constructor argument.
Apart from the variables delivered, it can be found other variables from other plugins and global variables that are not required by the specific plugin.