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, [fetchFn])

Create new router from configuration

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

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

Param Type Description
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, [fetchFn])

Create new router from configuration

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

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

Param Type Description
blocks Array.<object> blocks list
[plugins] Plugins
[context] object
 

Plugins

Custom code plugins for BuildRouter and wingbot.ai

Kind: global class

 

plugins.getWrappedPlugin(name, [paramsData], [items], [context])

Get plugin for the router

Kind: instance method of Plugins

Param Type
name string
[paramsData] object
[items] Map.<string, Array.<function()>>
[context] object
[context.isLastIndex] boolean
[context.router] Router

Example

const { Router } = require('wingbot');

const bot = new Router();

// simply
bot.use('simple-route', plugins.getWrappedPlugin('myCoolPLugin'));

// fully
bot.use('full-plugin-route', plugins
 .getWrappedPlugin(
    'fancyPLugin',
    { param: 123 },
    new Map([
      ['onSuccess', [(req, res) => { res.text('yes, success'); }]]
    ])
));
 

plugins.register(name, [plugin])

Register plugin

Kind: instance method of Plugins

Param Type Description
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

Param Type Description
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

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

results matching ""

    No results matching ""