MongoDB plugin for wingbot.ai
Contains storage for tokens, chat states, bot config and chat logs.
API
Classes
- StateStorage
Storage for chat states
- BotTokenStorage
Storage for webview tokens
- ChatLogStorage
Storage for conversation logs
- BotConfigStorage
Storage for wingbot.ai conversation config
Typedefs
- State :
Object
- Token :
Object
StateStorage
Storage for chat states
Kind: global class
new StateStorage(mongoDb, collectionName)
Param | Type | Default |
---|
mongoDb | mongodb.Db | Object | |
collectionName | string | "states" |
stateStorage._collection : mongodb.Collection
Kind: instance property of StateStorage
stateStorage._getCollection() ⇒ Promise.<mongodb.Collection>
Kind: instance method of StateStorage
stateStorage.getState(senderId, pageId) ⇒ Promise.<(State|null)>
Kind: instance method of StateStorage
Param | Type |
---|
senderId | string |
pageId | string |
stateStorage.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout]) ⇒ Promise.<Object>
Load state from database and lock it to prevent another reads
Kind: instance method of StateStorage
Returns: Promise.<Object>
- - conversation state
Param | Type | Default | Description |
---|
senderId | string | | sender identifier |
pageId | string | | page identifier |
[defaultState] | Object | | default state of the conversation |
[timeout] | number | 300 | given default state |
stateStorage.saveState(state) ⇒ Promise.<Object>
Save the state to database
Kind: instance method of StateStorage
Param | Type | Description |
---|
state | Object | conversation state |
BotTokenStorage
Storage for webview tokens
Kind: global class
new BotTokenStorage(mongoDb, collectionName)
Param | Type | Default |
---|
mongoDb | mongodb.Db | Object | |
collectionName | string | "tokens" |
botTokenStorage._collection : mongodb.Collection
Kind: instance property of BotTokenStorage
botTokenStorage._getCollection() ⇒ Promise.<mongodb.Collection>
Kind: instance method of BotTokenStorage
botTokenStorage.findByToken(token) ⇒ Promise.<(Token|null)>
Kind: instance method of BotTokenStorage
botTokenStorage.getOrCreateToken(senderId, pageId, createToken) ⇒ Promise.<(Token|null)>
Kind: instance method of BotTokenStorage
Param | Type |
---|
senderId | string |
pageId | string |
createToken | Object |
ChatLogStorage
Storage for conversation logs
Kind: global class
new ChatLogStorage(mongoDb, collectionName, [log])
Param | Type | Default | Description |
---|
mongoDb | mongodb.Db | Object | | |
collectionName | string | "chatlogs" | |
[log] | Object | | console like logger |
chatLogStorage._collection : mongodb.Collection
Kind: instance property of ChatLogStorage
chatLogStorage._getCollection() ⇒ Promise.<mongodb.Collection>
Kind: instance method of ChatLogStorage
chatLogStorage.log(senderId, responses, request)
Log single event
Kind: instance method of ChatLogStorage
Param | Type | Description |
---|
senderId | string | |
responses | Array.<Object> | list of sent responses |
request | Object | event request |
BotConfigStorage
Storage for wingbot.ai conversation config
Kind: global class
new BotConfigStorage(mongoDb, collectionName)
Param | Type | Default |
---|
mongoDb | mongodb.Db | Object | |
collectionName | string | "botconfig" |
botConfigStorage._collection : mongodb.Collection
Kind: instance property of BotConfigStorage
botConfigStorage._getCollection() ⇒ Promise.<mongodb.Collection>
Kind: instance method of BotConfigStorage
botConfigStorage.invalidateConfig() ⇒ Promise
Invalidates current configuration
Kind: instance method of BotConfigStorage
botConfigStorage.getConfigTimestamp() ⇒ Promise.<number>
Kind: instance method of BotConfigStorage
botConfigStorage.updateConfig(newConfig) ⇒ Promise.<T>
Kind: instance method of BotConfigStorage
Template: T
botConfigStorage.getConfig() ⇒ Promise.<(Object|null)>
Kind: instance method of BotConfigStorage
State : Object
Kind: global typedef
Properties
Name | Type |
---|
senderId | string |
pageId | string |
state | Object |
Token : Object
Kind: global typedef
Properties
Name | Type |
---|
senderId | string |
pageId | string |
token | string |