Classes

BuildRouter
BuildRouter
Plugins

Custom code plugins for BuildRouter and wingbot.ai

Typedefs

ConfigStorage : object
Plugin : function
 

BuildRouter

Kind: global class

 

new BuildRouter()

Build bot from Wingbot configuration file or snapshot url

 

new BuildRouter(block, plugins, context, [request])

Create new router from configuration

Params

  • block object
    • [.botId] string - the ID of bot
    • [.snapshot] string - snapshot stage of bot
    • [.token] string | Promise.<string> - authorization token for bot
    • [.url] string - specify alternative configuration resource
  • plugins Plugins - custom code blocks resource
  • context object - the building context
    • [.linksTranslator] object - function, that translates links globally
    • [.configStorage] ConfigStorage - function, that translates links globally
    • [.allowForbiddenSnippetWords] boolean - disable security rule
  • [request] function - the building context

Example

// usage of plugins

const { BuildRouter, Plugins } = require('wingbot');
const dynamoDb = require('./lib/dynamodb');
const config = require('./config');

const plugins = new Plugins();

plugins.register('exampleBlock', async (req, res, postBack) => {
    await res.run('responseBlockName');
});

const bot = new BuildRouter({
    botId: 'b7a71c27-c295-4ab0-b64e-6835b50a0db0',
    snapshot: 'master',
    token: 'adjsadlkadjj92n9u9'
}, plugins);

module.exports = bot;
 

buildRouter.keepConfigFor

Timeout, when the router is not checking for new configuration

Kind: instance property of BuildRouter
Properties

Type
number
 

buildRouter.loadBot() ⇒ Promise.<object>

Loads conversation configuration

Kind: instance method of BuildRouter

 

BuildRouter.fromData(blocks, plugins, [context])

Kind: static method of BuildRouter
Params

  • blocks Array.<object> - blocks list
  • plugins Plugins
  • [context] object
 

BuildRouter

Kind: global class

 

new BuildRouter()

Build bot from Wingbot configuration file or snapshot url

 

new BuildRouter(block, plugins, context, [request])

Create new router from configuration

Params

  • block object
    • [.botId] string - the ID of bot
    • [.snapshot] string - snapshot stage of bot
    • [.token] string | Promise.<string> - authorization token for bot
    • [.url] string - specify alternative configuration resource
  • plugins Plugins - custom code blocks resource
  • context object - the building context
    • [.linksTranslator] object - function, that translates links globally
    • [.configStorage] ConfigStorage - function, that translates links globally
    • [.allowForbiddenSnippetWords] boolean - disable security rule
  • [request] function - the building context

Example

// usage of plugins

const { BuildRouter, Plugins } = require('wingbot');
const dynamoDb = require('./lib/dynamodb');
const config = require('./config');

const plugins = new Plugins();

plugins.register('exampleBlock', async (req, res, postBack) => {
    await res.run('responseBlockName');
});

const bot = new BuildRouter({
    botId: 'b7a71c27-c295-4ab0-b64e-6835b50a0db0',
    snapshot: 'master',
    token: 'adjsadlkadjj92n9u9'
}, plugins);

module.exports = bot;
 

buildRouter.keepConfigFor

Timeout, when the router is not checking for new configuration

Kind: instance property of BuildRouter
Properties

Type
number
 

buildRouter.loadBot() ⇒ Promise.<object>

Loads conversation configuration

Kind: instance method of BuildRouter

 

BuildRouter.fromData(blocks, plugins, [context])

Kind: static method of BuildRouter
Params

  • blocks Array.<object> - blocks list
  • plugins Plugins
  • [context] object
 

Plugins

Custom code plugins for BuildRouter and wingbot.ai

Kind: global class

 

plugins.register(name, [plugin])

Register plugin

Kind: instance method of Plugins
Params

  • name string | Plugins - plugin name or plugins object to include
  • [plugin] Plugin | Router - plugin - optional when including plugin object
 

plugins.registerFactory(name, pluginFactory)

Register plugin factory

Kind: instance method of Plugins
Params

  • name string - plugin name or plugins object to include
  • pluginFactory function - function, which returns a plugin
 

ConfigStorage : object

Kind: global typedef
Properties

Name Type
invalidateConfig Object
getConfigTimestamp Object
updateConfig Object
getConfig Object
 

Plugin : function

Kind: global typedef
Params

  • req Request
  • res Responder
  • [postBack] function
  • [context] Object
  • [paramsData] object

results matching ""

    No results matching ""