Classes

Ai
WingbotModel
CachedModel

Typedefs

Intent : Object
Intent : Object
 

Ai

Kind: global class

 

ai.confidence : number

Upper threshold - for match method and for navigate method

Kind: instance property of Ai

 

ai.logger : Object

The logger (console by default)

Kind: instance property of Ai

 

ai.disableBookmarking : boolean

Backward compatibility - to be able to use older "callback" middleware

Kind: instance property of Ai

 

ai.getPrefix(prefix, req)

The prefix translator - for request-specific prefixes

Kind: instance method of Ai
Params

  • prefix string
  • req Request
 

ai.mockIntent([intent], [confidence]) ⇒ this

Usefull method for testing AI routes

Kind: instance method of Ai
Params

  • [intent] string = null - intent name
  • [confidence] number = - the confidence of the top intent

Example

const { Tester, ai, Route } = require('bontaut');

const bot = new Route();

bot.use(['intentAction', ai.match('intentName')], (req, res) => {
    res.text('PASSED');
});

describe('bot', function () {
    it('should work', function () {
        ai.mockIntent('intentName');

        const t = new Tester(bot);

        return t.text('Any text')
            .then(() => {
                t.actionPassed('intentAction');

            t.any()
                .contains('PASSED');
        })
    });
});
 

ai.register(model, prefix) ⇒ WingbotModel | T

Registers Wingbot AI model

Kind: instance method of Ai
Template: T
Params

  • model string | WingbotModel | T - wingbot model name or AI plugin
  • prefix string = "default" - model prefix
 

ai.load()

Middleware, which ensures, that AI data are properly loaded in Request

Kind: instance method of Ai
Example

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

const bot = new Router();

bot.use(ai.load());
 

ai.match(intent, [confidence]) ⇒ function

Returns matching middleware

supports:

  • intents (intentName)
  • wildcard keywords (#keyword#)
  • phrases (#first-phrase|second-phrase)
  • emojis (#😄🙃😛)

Kind: instance method of Ai
Returns: function - - the middleware
Params

  • intent string | Array
  • [confidence] number =

Example

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

ai.register('app-model');

bot.use(ai.match('intent1'), (req, res) => {
    console.log(req.intent(true)); // { intent: 'intent1', score: 0.9604 }

    res.text('Oh, intent 1 :)');
});
 

ai.globalMatch(intent, [confidence]) ⇒ function

Returns matching middleware, that will export the intent to the root router so the intent will be matched in a global context

Kind: instance method of Ai
Returns: function - - the middleware
Params

  • intent string | Array
  • [confidence] number =

Example

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

ai.register('app-model');

bot.use(ai.globalMatch('intent1'), (req, res) => {
    console.log(req.intent(true)); // { intent: 'intent1', score: 0.9604 }

    res.text('Oh, intent 1 :)');
});
 

WingbotModel

Kind: global class

 

new WingbotModel(options, [log])

Params

  • options Object
    • [.serviceUrl] string
    • .model string
    • [.cacheSize] number
    • [.matches] number
  • [log] Object
 

wingbotModel._queryModel(text) ⇒ Promise.<Array.<Intent>>

Kind: instance method of WingbotModel
Params

  • text string
 

CachedModel

Kind: global class

 

new CachedModel(options, [log])

Params

  • options Object
    • [.cacheSize] number
  • [log] Object
 

cachedModel.resolve(text) ⇒ Promise.<Array.<Intent>>

Kind: instance method of CachedModel
Params

  • text string - the user input
 

cachedModel._queryModel(text) ⇒ Promise.<Array.<Intent>>

Kind: instance method of CachedModel
Params

  • text string
 

Intent : Object

Kind: global typedef
Params

  • intent string
  • score number
  • [entities] Array.<Object>
 

Intent : Object

Kind: global typedef
Params

  • intent string
  • score number
  • [entities] Array.<Object>

results matching ""

    No results matching ""