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 - authorization token for bot
    • [.routes] Object - list of routes for direct bot build
    • [.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
  • [request] function - the building context

Example

// usage under serverless environment

const { Settings, BuildRouter, Blocks } = require(''wingbot');
const { createHandler, createProcessor } = require(''wingbot/serverlessAWS');
const dynamoDb = require('./lib/dynamodb');
const config = require('./config');

const blocks = new Blocks();

blocks.code('exampleBlock', async (req, res, postBack, context, params) => {
    await res.run('responseBlockName');
});

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

const processor = createProcessor(bot, {
    appUrl: config.pageUrl,
    pageToken: config.facebook.pageToken,
    appSecret: config.facebook.appSecret,
    autoTyping: true,
    dynamo: {
        db: dynamoDb,
        tablePrefix: `${config.prefix}-`
    }
});

const settings = new Settings(config.facebook.pageToken, log);

if (config.isProduction) {
    settings.getStartedButton('/start');
    settings.whitelistDomain(config.pageUrl);
}

module.exports.handleRequest = createHandler(processor, config.facebook.botToken);
 

buildRouter.keepConfigFor

Timeout, when the router is not checking for new configuration

Kind: instance property of BuildRouter
Properties

Type
number
 

BuildRouter.fromData(blocks, plugins)

Kind: static method of BuildRouter
Params

  • blocks Array.<Object> - blocks list
  • plugins Plugins
 

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 - authorization token for bot
    • [.routes] Object - list of routes for direct bot build
    • [.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
  • [request] function - the building context

Example

// usage under serverless environment

const { Settings, BuildRouter, Blocks } = require(''wingbot');
const { createHandler, createProcessor } = require(''wingbot/serverlessAWS');
const dynamoDb = require('./lib/dynamodb');
const config = require('./config');

const blocks = new Blocks();

blocks.code('exampleBlock', async (req, res, postBack, context, params) => {
    await res.run('responseBlockName');
});

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

const processor = createProcessor(bot, {
    appUrl: config.pageUrl,
    pageToken: config.facebook.pageToken,
    appSecret: config.facebook.appSecret,
    autoTyping: true,
    dynamo: {
        db: dynamoDb,
        tablePrefix: `${config.prefix}-`
    }
});

const settings = new Settings(config.facebook.pageToken, log);

if (config.isProduction) {
    settings.getStartedButton('/start');
    settings.whitelistDomain(config.pageUrl);
}

module.exports.handleRequest = createHandler(processor, config.facebook.botToken);
 

buildRouter.keepConfigFor

Timeout, when the router is not checking for new configuration

Kind: instance property of BuildRouter
Properties

Type
number
 

BuildRouter.fromData(blocks, plugins)

Kind: static method of BuildRouter
Params

  • blocks Array.<Object> - blocks list
  • plugins Plugins
 

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
 

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 ""