1.0.1 • Published 7 years ago

botmaster-enrich v1.0.1

Weekly downloads
130
License
MIT
Repository
github
Last release
7 years ago

Build Status Coverage Status

Enrich NLU contexts

Battle-tested middleware for botmaster http://botmasterai.com/).

Introduction

  • similar API to 'fulfill' middleware
  • allows caching of responses
  • manages merging
  • stuff anything else you need in your enrichers in params
  • callbacks, promises, and sync returns supported in controllers

Use cases

  • Scrapping websites for hours or telephone numbers to provide to bot
  • Validating user input

API

Enricher

Enricher Spec

The enricher spec is an object that describes an enricher

ParameterDescription
controllerFunction a controller that can return error last callback, a promise or sync. Called with (params, calback). Its result will be merged with the results from other controllers and the old context.
cacheBoolean whether or not to cache the result
ttlInteger if caching how long the result should stay cached in milliseconds

Enricher controller params

The following properties are available in params.

ParameterDescription
contextthe current context
updatein botmaster the update is provided
botin botmaster the bot is provided

Botmaster Ware

Enrich

Run the given enrichers with context and update the given old context. Return using the callback.

Parameters

  • options object options for the created middleware
    • options.enrichers object enrichers to run on the new context
    • options.params object? merged with the standard params passed to enricher controller

Returns enrich a function that can enrich context

enrich

Used to enrich a context

Parameters

  • context Object context to enrich
  • callback Function error first callback, returns enriched context

EnrichIncomingWare

Factory function to generate incoming ware for enrich

Parameters

  • $0 Object options
    • $0.enrichers Object an object of enrichers
    • $0.sessionPath String? dot denoted path find the context in the update. defaults to 'context'
    • $0.params Object? optional additional params to pass to enrichers

Returns Function botmaster middleware

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago