Classes

BotApp

Adapter for Wingbot flight director

Processor

Messaging event processor

Functions

afterProcessMessage(req, res)

Typedefs

Options : object
ApiResponse : object
AutoTypingConfig : object
Plugin : object
TrackingEvent : object
TrackingObject : object
InteractionEvent : object
IInteractionHandlerPromise | void
ILogger : object
ProcessorOptions : object
IntentAction : object
IStateStorage : object
PreloaderPromise.<void>
 

BotApp

Adapter for Wingbot flight director

Kind: global class

 

new BotApp(bot, options)

ParamType
botRouter
optionsOptions
 

botApp._eventHandlers : Array.<OnEventHandler>

Kind: instance property of BotApp

 

botApp.processor ⇒ Processor

Get the processor instance

Kind: instance property of BotApp

 

botApp.registerAnalyticsStorage(analyticsStorage, [options]) ⇒ this

Kind: instance method of BotApp

ParamType
analyticsStorageIAnalyticsStorage
[options]HandlerConfig

Example

const { GA4 } = require('wingbot');
botApp.registerAnalyticsStorage(new GA4({
measurementId: 'G-123456,
apiSecret: 'apisecret'
}))
 

botApp.trackEvent(pageId, senderId, event, [ts], [nonInteractive])

Method for tracking special events

Kind: instance method of BotApp

ParamTypeDefault
pageIdstring
senderIdstring
eventEvent
[ts]number
[nonInteractive]booleanfalse
 

botApp._processSenderResponses(sender, senderId, pageId, headers)

Kind: instance method of BotApp

ParamType
senderReturnSender
senderIdstring
pageIdstring
headersobject
 

botApp.createSender(senderId, pageId, [message], [secret], appId) ⇒ Promise.<BotAppSender>

Creates a Sender to be able, for example, to upload files

Kind: instance method of BotApp

ParamType
senderIdstring
pageIdstring
[message]object
[secret]string | Promise.<string>
appIdstring
 

botApp.processMessage(message, senderId, pageId, data) ⇒ Promise.<{status:number}>

Compatibility method for Notification engine

Kind: instance method of BotApp

ParamTypeDescription
messageobjectwingbot chat event
senderIdstringchat event sender identifier
pageIdstringchannel/page identifier
dataobjectcontextual data (will be available in res.data)
[data.appId]stringpossibility to override appId
 

botApp.request(rawBody, rawHeaders) ⇒ Promise.<ApiResponse>

Process incomming API request from the orchestrator.

The response can be sent using an express, or you can directly return the response to

Kind: instance method of BotApp

ParamType
rawBodystring | null
rawHeadersobject

Example

const express = require('express');
const { Router, BotApp } = require('express');
const app = express();
const bot = new Router();
bot.use((req, res) => { res.text('hello!'); });
const botApp = new BotApp(bot, {
apiUrl: 'https://<url to orchestrator>',
secret: '<application secret in orchestrator>'
});
app.get('/bot', express.text(), (req, res) => {
botApp.request(req.body, req.headers)
.then((response) => {
const { body, statusCode, headers } = response;
res.status(statusCode)
.set(headers)
.send(body);
})
});
 

BotApp.signBody(body, secret, appId) ⇒ Promise.<string>

Get authorization token for wingbot orchestrator

Kind: static method of BotApp

ParamType
bodystring
secretstring
appIdstring
 

BotApp.plugin() ⇒ Plugin

Returns processor plugin, which updates thread context automatically

Kind: static method of BotApp

 

BotApp.sendContext(req, res)

Kind: static method of BotApp

ParamType
reqRequest
resResponder
 

afterProcessMessage(req, res)

Kind: global function

ParamType
reqRequest
resResponder
 

Options : object

Kind: global typedef
Properties

NameTypeDescription
secretstring | Promise.<string>
[appId]stringfor notifications
[apiUrl]string
[fetch]function
[chatLogStorage]ChatLogStorage
[preferSynchronousResponse]boolean
[auditLog]AuditLog
[tls]TlsOptions
 

ApiResponse : object

Kind: global typedef
Properties

NameType
statusCodenumber
bodystring
headersobject
 

AutoTypingConfig : object

Kind: global typedef
Properties

NameTypeDescription
timenumberduration
perCharactersnumbernumber of characters
minTimenumberminimum writing time
maxTimenumbermaximum writing time
 

Plugin : object

Kind: global typedef
Properties

NameType
[processMessage]function
[beforeAiPreload]function
[beforeProcessMessage]function
[afterProcessMessage]function
 

TrackingEvent : object

Kind: global typedef
Properties

NameType
typeTrackingType
categoryTrackingCategory
actionstring
labelstring
valuenumber
 

TrackingObject : object

Kind: global typedef
Properties

NameType
eventsArray.<TrackingEvent>
 

InteractionEvent : object

Kind: global typedef
Properties

NameTypeDescription
reqRequest
actionsArray.<string>
lastActionstring | null
stateobject
dataobject
skillstring | null
prevSkillstring | null
pathnamestring | null
trackingTrackingObjectdeprecated
eventsArray.<TrackingEvent>
flagResponseFlag | null
nonInteractiveboolean
responseTextsArray.<string>
doNotTrackboolean
 

IInteractionHandler ⇒ Promise | void

Kind: global typedef

ParamType
paramsInteractionEvent
 

ILogger : object

Kind: global typedef
Properties

NameType
logfunction
warnfunction
errorfunction
 

ProcessorOptions : object

Kind: global typedef
Properties

NameTypeDescription
[appUrl]stringurl basepath for relative links
[stateStorage]IStateStoragechatbot state storage
[tokenStorage]objectfrontend token storage
[translator]functiontext translate function
[timeout]numberchat sesstion lock duration (30000)
[justUpdateTimeout]numbersimple read and write lock (1000)
[waitForLockedState]numberwait when state is locked (12000)
[retriesWhenWaiting]numbernumber of attampts (6)
[nameFromState]functionoverride the name translator
[autoTyping]boolean | AutoTypingConfigenable or disable automatic typing
[log]ILoggerconsole like error logger
[defaultState]objectdefault chat state
[autoSeen]booleansend seen automatically
[redirectLimit]numbermaximum number of redirects at single request
[secret]stringSecret for calling orchestrator API
[apiUrl]stringUrl for calling orchestrator API
[fetch]functionFetch function for calling orchestrator API
[sessionDuration]numberSession duration for analytic purposes
[preloader]Preloader.<R>
 

IntentAction : object

Kind: global typedef
Properties

NameType
actionstring
intentIntent
sortnumber
[score]number
localboolean
aboveConfidenceboolean
[winner]boolean
metaobject
titlestring
[meta.targetAppId]string
[meta.targetAction]string | null
 

IStateStorage : object

Kind: global typedef
Properties

NameType
saveStatefunction
getStatefunction
getOrCreateAndLockfunction
 

Preloader ⇒ Promise.<void>

Kind: global typedef

ParamType
routerT
aiAi