Classes

MemoryStateStorage

Memory conversation state storage for testing purposes

ReturnSender

Functions

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

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

compileWithState(req, res, template)string

Utility, which helps to render handlebars syntax with all variables within conversations state

makeExpectedKeyword(action, title, [matcher], [payloadData], [setState], [aiTitle])ExpectedKeyword
disambiguationQuickReply(title, likelyIntent, disambText, action, data)

Create a disambiguation quick reply

Typedefs

ExpectedKeyword : object
QuickReplyAction : object
State : object
StateCondition : object
GetInteractionsPromise.<Array.<object>>
ChatLogStorage : object
ReturnSenderOptions : object
UploadResult : object
DeferOperationPromise.<any>
ErrorLogger : object
SendOptions : 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

ParamType
senderIdstring
pageIdstring
 

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

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

ParamTypeDefaultDescription
senderIdstringsender identifier
pageIdstringpage or channel identifier
defaultStateobjectdefault state of the conversation
lockTimeoutnumber300duration of lock
 

memoryStateStorage.saveState(state) ⇒ Promise

Kind: instance method of MemoryStateStorage

ParamTypeDescription
stateobjectconversation state
 

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

Kind: instance method of MemoryStateStorage

ParamTypeDefault
conditionStateCondition
limitnumber20
lastKeystringnull
 

ReturnSender

Kind: global class

 

new ReturnSender(options, senderId, incommingMessage, logger)

ParamTypeDefaultDescription
optionsReturnSenderOptions
senderIdstring
incommingMessageobject
loggerChatLogStorageconsole like logger
 

returnSender.responses : Array.<object>

Kind: instance property of ReturnSender

 

returnSender._responseOptions : Array.<SendOptions>

Kind: instance property of ReturnSender

 

returnSender.waits : boolean

Kind: instance property of ReturnSender

 

returnSender.textFilter : TextFilter

Preprocess text for NLP For example to remove any confidential data

Kind: instance property of ReturnSender

ParamType
textstring
 

returnSender.requestTexts ⇒ Array.<string>

Kind: instance property of ReturnSender

 

returnSender.responseTexts ⇒ Array.<string>

Kind: instance property of ReturnSender

 

returnSender.chatLogStorage ⇒ ChatLogStorage

Kind: instance property of ReturnSender

 

returnSender.tracking ⇒ TrackingObject

Kind: instance property of ReturnSender

 

returnSender.defer(operation, logger)

Kind: instance method of ReturnSender

ParamType
operationDeferOperation | Promise
loggerErrorLogger
 

returnSender.upload(data, contentType, fileName) ⇒ Promise.<UploadResult>

Kind: instance method of ReturnSender

ParamType
dataBuffer
contentTypestring
fileNamestring
 

returnSender.send(payload, options) ⇒ void

Kind: instance method of ReturnSender

ParamType
payloadobject
optionsSendOptions
 

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

Kind: instance method of ReturnSender

 

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

Kind: instance method of ReturnSender

 

returnSender.finished([req], [res], [err], [reportError]) ⇒ Promise.<Object>

Kind: instance method of ReturnSender

ParamTypeDefault
[req]Request
[res]Responder
[err]Error
[reportError]function
 

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

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

Kind: global function

ParamTypeDefaultDescription
urlstring
[limit]number0limit in bytes
[limitJustByBody]booleanfalsewhen true, content size in header is ignored
[redirCount]number3maximmum 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 }))
}
});
 

compileWithState(req, res, template) ⇒ string

Utility, which helps to render handlebars syntax with all variables within conversations state

Kind: global function

ParamType
reqRequest
resResponder
templatestring

Example

const { compileWithState } = require('wingbot');
function myPluginFactory (params) {
return (req, res) => {
const text = compileWithState(req, res, params.text);
res.text(text);
};
}
 

makeExpectedKeyword(action, title, [matcher], [payloadData], [setState], [aiTitle]) ⇒ ExpectedKeyword

Kind: global function

ParamTypeDefault
actionstring
titlestring
[matcher]RegExp | string | Array.<string>
[payloadData]object
[setState]object
[aiTitle]stringnull
 

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

Deprecated

Create a disambiguation quick reply

Kind: global function

ParamTypeDescription
titlestringquick reply title
likelyIntentstringpossible intent
disambTextstringusers text input
actionstringaction to process the disambbiguation
dataobjectoptional data
 

ExpectedKeyword : object

Kind: global typedef
Properties

NameType
actionstring
titlestring
matchnull | string | Array.<string>
dataobject
[hasAiTitle]boolean
[setState]object
 

QuickReplyAction : object

Kind: global typedef
Properties

NameType
aboveConfidenceboolean
actionstring
titlestring
matchnull | string | Array.<string>
dataobject
scorenumber
sortnumber
[title]string
[setState]object
[_aiKeys]Array.<string>
[intent]Intent
 

State : object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring
stateobject
 

StateCondition : object

Kind: global typedef
Properties

NameType
[search]string
 

GetInteractions ⇒ Promise.<Array.<object>>

Kind: global typedef

ParamTypeDescription
senderIdstring
pageIdstring
[limit]number
[endAt]numberiterate backwards to history
[startAt]numberiterate forward to last interaction
 

ChatLogStorage : object

Kind: global typedef
Properties

NameType
logfunction
errorfunction
[getInteractions]GetInteractions
 

ReturnSenderOptions : object

Kind: global typedef
Properties

NameTypeDescription
[dontWaitForDeferredOps]boolean
[textFilter]TextFilterfilter for saving the texts
[logStandbyEvents]booleanlog the standby events
[confidentInputFilter]TextFilterfilter for confident input (@CONFIDENT)
 

UploadResult : object

Kind: global typedef
Properties

NameType
[url]string
[attachmentId]string | number
 

DeferOperation ⇒ Promise.<any>

Kind: global typedef

 

ErrorLogger : object

Kind: global typedef
Properties

NameType
errorfunction
 

SendOptions : object

Kind: global typedef
Properties

NameType
[anonymizer]TextFilter
 

TextFilter ⇒ string

Text filter function

Kind: global typedef
Returns: string - - filtered text

ParamTypeDescription
textstringinput text
key'text' | 'title' | 'url' | 'content'