Classes

BuildRouter
BuildRouter
Blocks

Custom code blocks for BuildRouter and wingbot.ai

 

BuildRouter

Kind: global class

 

new BuildRouter()

Build bot from Wingbot configuration file or snapshot url

 

new BuildRouter(block, blocksResource)

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 authorization token for bot
[block.routes] object list of routes for direct bot build
[block.url] string specify alternative configuration resource
blocksResource Blocks custom code blocks resource

Example

// usage under serverless environment

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

const blocks = new Blocks();

blocks.code('exampleBlock', function* (req, res, postBack, context, params) {
    yield 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.fromData()

Kind: static method of BuildRouter

 

BuildRouter

Kind: global class

 

new BuildRouter()

Build bot from Wingbot configuration file or snapshot url

 

new BuildRouter(block, blocksResource)

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 authorization token for bot
[block.routes] object list of routes for direct bot build
[block.url] string specify alternative configuration resource
blocksResource Blocks custom code blocks resource

Example

// usage under serverless environment

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

const blocks = new Blocks();

blocks.code('exampleBlock', function* (req, res, postBack, context, params) {
    yield 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.fromData()

Kind: static method of BuildRouter

 

Blocks

Custom code blocks for BuildRouter and wingbot.ai

Kind: global class

 

blocks.resolver(type, factoryFn)

Register resolver factory

Kind: instance method of Blocks

Param Type Description
type string resolver type
factoryFn function resolver factory
 

blocks.code(name, [factoryFn])

Register custom code block

Kind: instance method of Blocks

Param Type Default Description
name string \ Blocks block name or blocks object to include
[factoryFn] string null block factory - optional when including another blocks object

results matching ""

    No results matching ""