Classes

MemoryStateStorage

Memory conversation state storage for testing purposes

Translate
Translate
ReturnSender

Constants

FLAG_DISAMBIGUATION_SELECTED

Disambiguation quick reply was selected

FLAG_DISAMBIGUATION_OFFERED

Disambiguation occured - user was asked to choose the right meaning

FLAG_DO_NOT_LOG

Do not log the event

Functions

bufferloader(url, [limit], [limitJustByBody], [redirCount])Promise.<Buffer>

Downloads a file from url into a buffer. Supports size limits and redirects.

disambiguationQuickReply(title, likelyIntent, disambText, action, data)

Create a disambiguation quick reply

Typedefs

State : object
StateCondition : object
textFilterstring

Text filter function

 

MemoryStateStorage

Memory conversation state storage for testing purposes

Kind: global class

 

memoryStateStorage.getState(senderId, pageId) ⇒ Promise.<(State|null)>

Kind: instance method of MemoryStateStorage

Param Type
senderId string
pageId string
 

memoryStateStorage.getOrCreateAndLock(senderId, pageId, defaultState, lockTimeout) ⇒ Promise.<State>

Kind: instance method of MemoryStateStorage
Returns: Promise.<State> - - conversation state

Param Type Default Description
senderId string sender identifier
pageId string page or channel identifier
defaultState object default state of the conversation
lockTimeout number 300 duration of lock
 

memoryStateStorage.saveState(state) ⇒ Promise

Kind: instance method of MemoryStateStorage

Param Type Description
state object conversation state
 

memoryStateStorage.getStates(condition, limit, lastKey) ⇒ Promise.<{Array.<data:State>, lastKey:string}>

Kind: instance method of MemoryStateStorage

Param Type Default
condition StateCondition
limit number 20
lastKey string null
 

Translate

Kind: global class

 

new Translate()

Tool for text translation

 

new Translate([options])

Param Type Description
[options] object
[options.sourcePath] string optional source path of translation folder
[options.fileSuffix] string by default .locale.po
 

translate.translator(languages) ⇒ Promise.<object>

Creates static translator for static settings

Kind: instance method of Translate

Param Type Description
languages Array.<string> list of required languages

Example

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

const translate = new Translate({ sourcePath: __dirname });

const t = translate.translator(['cs', 'en']);

// czech
t.cs.t('requested text');

// english
t.en.t('requested text');
 

translate.middleware(languageResolver) ⇒ function

Bots middleware for text translations

  • will be looking for <lang>.locale.po by default

Kind: instance method of Translate

Param Type
languageResolver function

Example

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

const translate = new Translate({ sourcePath: __dirname });

bot.use(translate.middleware((req, res) => 'cs'));

bot.use((req, res) => {
   res.text(res.t('Translated text'));
});
 

Translate

Kind: global class

 

new Translate()

Tool for text translation

 

new Translate([options])

Param Type Description
[options] object
[options.sourcePath] string optional source path of translation folder
[options.fileSuffix] string by default .locale.po
 

translate.translator(languages) ⇒ Promise.<object>

Creates static translator for static settings

Kind: instance method of Translate

Param Type Description
languages Array.<string> list of required languages

Example

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

const translate = new Translate({ sourcePath: __dirname });

const t = translate.translator(['cs', 'en']);

// czech
t.cs.t('requested text');

// english
t.en.t('requested text');
 

translate.middleware(languageResolver) ⇒ function

Bots middleware for text translations

  • will be looking for <lang>.locale.po by default

Kind: instance method of Translate

Param Type
languageResolver function

Example

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

const translate = new Translate({ sourcePath: __dirname });

bot.use(translate.middleware((req, res) => 'cs'));

bot.use((req, res) => {
   res.text(res.t('Translated text'));
});
 

ReturnSender

Kind: global class

 

new ReturnSender(options, userId, incommingMessage, logger)

Param Type Description
options object
[options.textFilter] textFilter filter for saving the texts
[options.logStandbyEvents] boolean log the standby events
[options.confidentInputFilter] textFilter filter for confident input (@CONFIDENT)
userId string
incommingMessage object
logger console console like logger
 

returnSender.textFilter : textFilter

Preprocess text for NLP For example to remove any confidential data

Kind: instance property of ReturnSender

Param Type
text string
 

returnSender.modifyStateAfterLoad() ⇒ Promise.<(object|null)>

Kind: instance method of ReturnSender

 

returnSender.modifyStateBeforeStore() ⇒ Promise.<(object|null)>

Kind: instance method of ReturnSender

 

FLAG_DISAMBIGUATION_SELECTED

Disambiguation quick reply was selected

Kind: global constant

 

FLAG_DISAMBIGUATION_OFFERED

Disambiguation occured - user was asked to choose the right meaning

Kind: global constant

 

FLAG_DO_NOT_LOG

Do not log the event

Kind: global constant

 

bufferloader(url, [limit], [limitJustByBody], [redirCount]) ⇒ Promise.<Buffer>

Downloads a file from url into a buffer. Supports size limits and redirects.

Kind: global function

Param Type Default Description
url string
[limit] number 0 limit in bytes
[limitJustByBody] boolean false when true, content size in header is ignored
[redirCount] number 3 maximmum amount of redirects

Example

router.use('*', (req, res, postBack) => {
    if (req.isFile()) {
        bufferloader(req.attachmentUrl())
            .then(buffer => postBack('downloaded', { data: buffer }))
            .catch(err => postBack('donwloaded', { err }))
    }
});
 

disambiguationQuickReply(title, likelyIntent, disambText, action, data)

Create a disambiguation quick reply

Kind: global function

Param Type Description
title string quick reply title
likelyIntent string possible intent
disambText string users text input
action string action to process the disambbiguation
data object optional data
 

State : object

Kind: global typedef
Properties

Name Type
senderId string
pageId string
state object
 

StateCondition : object

Kind: global typedef
Properties

Name Type
[search] string
 

textFilter ⇒ string

Text filter function

Kind: global typedef
Returns: string - - filtered text

Param Type Description
text string input text

results matching ""

    No results matching ""