Class: SkillVCFactory

SkillVCFactory

new SkillVCFactory()

SkillVCFactory makes it simple to have a fully functional VC (view / controller) system by simply making a one line index.js for your skill.
Source:
Example

Example usage of SkillVCFactory

var SkillVCFactory = require('./lib/skillVCFactory.js');

exports.handler = function(event, context) {
	  SkillVCFactory.createfromDirectory().handler(event, context);
}

Methods

(static) createFromConfig(config) → {SkillVC}

Creates an instance of SkillVC that uses a JSON configuration to determine where the various objects are and how they map to intents. This is the most efficient way to run SkilLVC as it does not have to scan files to determine what to load, however it requires the creation and maintenance of a JSON file
Parameters:
Name Type Description
config JSON The configuration of the filters, intent handlers, and other code points
Source:
To Do:
  • Implement this
Returns:
An instance of SkillVC configured based on the passed in configuration
Type
SkillVC

(static) createfromDirectory(dir) → {SkillVC}

Creates and instance of SkillVC using Convention-over-Configuration. Assest (responses, filters, and intent handlers) are placed in their respective directories and processed when required. It uses the Handlebars response formatter to allow the most dynamic modification of responses. This method of configuration is the most straightforward and allows for a clear separation of concerns. For most simple applications that do not require the quickest execution, this is the best choice. The directories it will search are: - {app_root}/responses - {app_root}/filters - {app_root}/intents where {app_root} is the detected root of the application
Parameters:
Name Type Description
dir Sring The root directory to use. Defaults to '.'
Source:
See:
  • ResponseManagerFactory#createHandlebarEnabledByDirectory
  • FilterManagerFactory#createByDirectory
  • IntentHandlerManagerFactory"createByDirectory
To Do:
  • This is currently coded to use ../assets which is specific to my test implemenation
Returns:
An instance of SkillVC configured based on the passed in configuration
Type
SkillVC

(static) createFromScan(files) → {SkillVC}

Creates an instance of SkillVC by scanning the passed in files. This is the slowest method of starting SkillVC as it requires the synchronous loading and parsing of every specified file prior to actual skill handling. This method of configuration has the advantage of supporting javascript objects that can be both filters, intent handlers, and session handlers as the scan will look for everything in each file. Responses, as they are pure JSON, they are detected by the name of the file (.json)
Parameters:
Name Type Description
files Array.String The files to scan
Source:
To Do:
  • Implement this
Returns:
An instance of SkillVC configured based on the passed in configuration
Type
SkillVC