Categories:
Aura Bot configuration
Description of Aura Bot configuration basics, nomenclature, environment variables and libraries configuration
Introduction
The current section includes:
- Configuration basics: process and priorities, nomenclature, validation of the configuration, etc.
- Aura channels configuration
- Updated list of Aura Bot environment variables
- Aura Bot libraries configuration and variables
Configuration basics
Process and priorities
Aura components environment configuration will be loaded merging the variables defined in the environment of the host running the server and those defined in a configuration file, that will be passed to the server as an environment variable named CONFIG_FILE.
Variable values defined in the host environment will take precedence to those defined in the CONFIG_FILE.
Finally, variables collected by the make-up process of the external libraries .env.libraries will be loaded with less priority (as if they had been defined in the environment or in the CONFIG_FILE, they will have more priority).
Afterwards, all variables are joined together and, in case the same variable key is used twice, the priority will be as follows (the higher in the list, the more priority):
- Vars from the environment
- Vars from the file pointed by
CONFIG_FILE - Vars from
.env.libraries(in aura-bot root, autogenerated file)
Nomenclature
-
Environment variables names should start with
AURA_in main Aura components, to avoid problems with the overlapping of system variables. -
Environment variables used in aura-bot libraries should start with the name of the library (
BILL_), to isolate variable names and avoid overwriting between different libraries.
Note:
Review carefully with the DevOps Team variable names that are set automatically by kubernetes, such as [APP_NAME]_PORT that has the docker host of the k8s cluster.
In the case of aura-bot pods, it will be: AURA_BOT_PORT. So, this variable must not be used internally.
Configuration validation
aura-bot counts on a @hapi/joi validation schema that will contain the variables used by it.
During the start-up process, if the validation of global configuration fails, the full list of variables to fix will be shown and the bot will not start. See libraries configuration for further information.
Once the configuration is loaded and the instance created, it will count on the property environmentConfiguration, that contains all the variables set in the system. The names of the variables will be the same than the environment variables, just the type will be set during the schema validation.
For a complete list of environment variables in the system, check aura-bot environment variables.
Passing configuration to our internal libraries
aura-bot internal modules such as the server, middlewares and all of our internal libraries (aura-kpis, aura-logging, aura-locale-manager, etc.) must be prepared to get the configuration when creating an instance.
They should provide a constructor or an init method, with a configuration argument, to receive the environment configuration, for example:
export class SingletonModule {
/** Private constructor to avoid unwanted instances */
private constructor() { }
readonly id: string = 'SingletonModule';
public static init(configuration: Configuration): SingletonModule {
if (!SingletonModule.instance) {
// Do initializing stuff
return SingletonModule.instance;
} else {
throw new Error('An instance of SingletonModule already exists');
}
}
/** Module internal instance */
private static instance: SingletonModule;
}
Aura Channels configuration
The list of channels available in the environment includes the channel name, id, basic channel configuration, response type, enabled purposes in Kernel, etc. This setting is configured in aura-configuration-api server.
In principle, this setting should not be modified by the OB developers, as it is automatically modified during the make-up phase. However, it is recommended recommended that local developers use their own aura-configuration API server and can make changes for local testing purposes.
You can find detailed information regarding the channel configuration file in Channel Model section.
AuraChannelsConfiguration is a singleton class that contains utils to obtain information about the channels. This module is initialized at server start-up like other singleton modules. To use it, you should use the instance already created:
const configuration = {
AURA_CHANNELS_CONFIGURATION_API_ENDPOINT: 'http://...' // Mandatory.
};
AuraChannelsConfiguration.init(configuration);
The variable AURA_CHANNELS_CONFIGURATION_API_ENDPOINT contains the URL to access aura-configuration-api service. AuraChannelsConfiguration uses the following methods:
getChannelByName
Get channel configuration value by name of channel.AuraChannelsConfiguration.instance.getChannelByName('channelName');getChannelByPrefix
Get channel configuration value by prefix of channel.AuraChannelsConfiguration.instance.getChannelByPrefix('channelPrefix');getChannelById
Get channel configuration value by id of channel.AuraChannelsConfiguration.instance.getChannelById('channelId');`getChannels
Get all channels configuration.AuraChannelsConfiguration.instance.getChannels();