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
- GetInteractions ⇒
Promise.<Array.<object>>
- ChatLogStorage :
object
- ReturnSenderOptions :
object
- UploadResult :
object
- DeferOperation ⇒
Promise.<any>
- ErrorLogger :
object
- SendOptions :
object
- TextFilter ⇒
string
Text filter function
MemoryStateStorage
Memory conversation state storage for testing purposes
Kind: global class
- MemoryStateStorage
- .getState(senderId, pageId) ⇒
Promise.<(State|null)>
- .getOrCreateAndLock(senderId, pageId, defaultState, lockTimeout) ⇒
Promise.<State>
- .saveState(state) ⇒
Promise
- .getStates(condition, limit, lastKey) ⇒
Promise.<{Array.<data:State>, lastKey:string}>
- .getState(senderId, pageId) ⇒
Promise.<(State|null)>
memoryStateStorage.getState(senderId, pageId) ⇒ Kind: instance method of MemoryStateStorage
Param | Type |
---|---|
senderId | string |
pageId | string |
Promise.<State>
memoryStateStorage.getOrCreateAndLock(senderId, pageId, defaultState, lockTimeout) ⇒ 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 |
Promise
memoryStateStorage.saveState(state) ⇒ Kind: instance method of MemoryStateStorage
Param | Type | Description |
---|---|---|
state | object | conversation state |
Promise.<{Array.<data:State>, lastKey:string}>
memoryStateStorage.getStates(condition, limit, lastKey) ⇒ Kind: instance method of MemoryStateStorage
Param | Type | Default |
---|---|---|
condition | StateCondition | |
limit | number | 20 |
lastKey | string | null |
ReturnSender
Kind: global class
- ReturnSender
- new ReturnSender(options, senderId, incommingMessage, logger)
- .responses :
Array.<object>
- ._responseOptions :
Array.<SendOptions>
- .waits :
boolean
- .textFilter :
TextFilter
- .requestTexts ⇒
Array.<string>
- .responseTexts ⇒
Array.<string>
- .chatLogStorage ⇒
ChatLogStorage
- .tracking ⇒
TrackingObject
- .defer(operation, logger)
- .upload(data, contentType, fileName) ⇒
Promise.<UploadResult>
- .send(payload, options) ⇒
void
- .modifyStateAfterLoad() ⇒
Promise.<(object|null)>
- .modifyStateBeforeStore() ⇒
Promise.<(object|null)>
- .finished([req], [res], [err], [reportError]) ⇒
Promise.<Object>
new ReturnSender(options, senderId, incommingMessage, logger)
Param | Type | Default | Description |
---|---|---|---|
options | ReturnSenderOptions | ||
senderId | string | ||
incommingMessage | object | ||
logger | ChatLogStorage |
| console like logger |
Array.<object>
returnSender.responses : Kind: instance property of ReturnSender
Array.<SendOptions>
returnSender._responseOptions : Kind: instance property of ReturnSender
boolean
returnSender.waits : Kind: instance property of ReturnSender
TextFilter
returnSender.textFilter : Preprocess text for NLP For example to remove any confidential data
Kind: instance property of ReturnSender
Param | Type |
---|---|
text | string |
Array.<string>
returnSender.requestTexts ⇒ Kind: instance property of ReturnSender
Array.<string>
returnSender.responseTexts ⇒ Kind: instance property of ReturnSender
ChatLogStorage
returnSender.chatLogStorage ⇒ Kind: instance property of ReturnSender
TrackingObject
returnSender.tracking ⇒ Kind: instance property of ReturnSender
returnSender.defer(operation, logger)
Kind: instance method of ReturnSender
Param | Type |
---|---|
operation | DeferOperation | Promise |
logger | ErrorLogger |
Promise.<UploadResult>
returnSender.upload(data, contentType, fileName) ⇒ Kind: instance method of ReturnSender
Param | Type |
---|---|
data | Buffer |
contentType | string |
fileName | string |
void
returnSender.send(payload, options) ⇒ Kind: instance method of ReturnSender
Param | Type |
---|---|
payload | object |
options | SendOptions |
Promise.<(object|null)>
returnSender.modifyStateAfterLoad() ⇒ Kind: instance method of ReturnSender
Promise.<(object|null)>
returnSender.modifyStateBeforeStore() ⇒ Kind: instance method of ReturnSender
Promise.<Object>
returnSender.finished([req], [res], [err], [reportError]) ⇒ Kind: instance method of ReturnSender
Param | Type | Default |
---|---|---|
[req] | Request |
|
[res] | Responder |
|
[err] | Error |
|
[reportError] | function |
Promise.<Buffer>
bufferloader(url, [limit], [limitJustByBody], [redirCount]) ⇒ 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 }))}});
string
compileWithState(req, res, template) ⇒ Utility, which helps to render handlebars syntax with all variables within conversations state
Kind: global function
Param | Type |
---|---|
req | Request |
res | Responder |
template | string |
Example
const { compileWithState } = require('wingbot');function myPluginFactory (params) {return (req, res) => {const text = compileWithState(req, res, params.text);res.text(text);};}
ExpectedKeyword
makeExpectedKeyword(action, title, [matcher], [payloadData], [setState], [aiTitle]) ⇒ Kind: global function
Param | Type | Default |
---|---|---|
action | string | |
title | string | |
[matcher] | RegExp | string | Array.<string> |
|
[payloadData] | object | |
[setState] | object |
|
[aiTitle] | string | null |
disambiguationQuickReply(title, likelyIntent, disambText, action, data)
Deprecated
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 |
object
ExpectedKeyword : Kind: global typedef
Properties
Name | Type |
---|---|
action | string |
title | string |
match | null | string | Array.<string> |
data | object |
[hasAiTitle] | boolean |
[setState] | object |
object
QuickReplyAction : Kind: global typedef
Properties
Name | Type |
---|---|
aboveConfidence | boolean |
action | string |
title | string |
match | null | string | Array.<string> |
data | object |
score | number |
sort | number |
[title] | string |
[setState] | object |
[_aiKeys] | Array.<string> |
[intent] | Intent |
object
State : Kind: global typedef
Properties
Name | Type |
---|---|
senderId | string |
pageId | string |
state | object |
object
StateCondition : Kind: global typedef
Properties
Name | Type |
---|---|
[search] | string |
Promise.<Array.<object>>
GetInteractions ⇒ Kind: global typedef
Param | Type | Description |
---|---|---|
senderId | string | |
pageId | string | |
[limit] | number | |
[endAt] | number | iterate backwards to history |
[startAt] | number | iterate forward to last interaction |
object
ChatLogStorage : Kind: global typedef
Properties
Name | Type |
---|---|
log | function |
error | function |
[getInteractions] | GetInteractions |
object
ReturnSenderOptions : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[dontWaitForDeferredOps] | boolean | |
[textFilter] | TextFilter | filter for saving the texts |
[logStandbyEvents] | boolean | log the standby events |
[confidentInputFilter] | TextFilter | filter for confident input (@CONFIDENT) |
object
UploadResult : Kind: global typedef
Properties
Name | Type |
---|---|
[url] | string |
[attachmentId] | string | number |
Promise.<any>
DeferOperation ⇒ Kind: global typedef
object
ErrorLogger : Kind: global typedef
Properties
Name | Type |
---|---|
error | function |
object
SendOptions : Kind: global typedef
Properties
Name | Type |
---|---|
[anonymizer] | TextFilter |
string
TextFilter ⇒ Text filter function
Kind: global typedef
Returns: string
- - filtered text
Param | Type | Description |
---|---|---|
text | string | input text |
key | 'text' | 'title' | 'url' | 'content' |