Classes
Constants
- FEATURE_VOICE :
string
channel supports voice messages
- FEATURE_SSML :
string
channel supports SSML voice messages
- FEATURE_PHRASES :
string
channel supports expected phrases messages
- FEATURE_TEXT :
string
channel supports text communication
- FEATURE_TRACKING :
string
channel supports tracking protocol
- FEATURE_VOICE :
string
channel supports voice messages
- FEATURE_SSML :
string
channel supports SSML voice messages
- FEATURE_PHRASES :
string
channel supports expected phrases messages
- FEATURE_TEXT :
string
channel supports text communication
- FEATURE_TRACKING :
string
channel supports tracking protocol
Typedefs
- Entity :
object
- Intent :
object
- Action :
object
- IntentAction :
object
- QuickReply :
object
- QuickReplyDisambiguation :
object
- RequestOrchestratorOptions :
object
- TextAlternative :
object
- Attachment :
object
- AiSetStateOption :
number
Request
Kind: global class
- Request
- new Request()
- new Request(event, state, pageId, globalIntents, [orchestratorOptions], [configuration])
- .params
- .attachments :
Array.<Attachment>
- .timestamp :
number
|null
- .senderId :
string
- .recipientId :
string
- .pageId :
string
- .state :
S
- .features :
Array.<string>
- .subscribtions :
Array.<string>
- .entities :
Array.<Entity>
- .intents :
Array.<Intent>
- ._orchestratorClientOptions :
OrchestratorClientOptions
- .configuration :
C
- .event :
object
- .AI_SETSTATE :
enum
- .supportsFeature(feature) ⇒
boolean
- .isStandby() ⇒
boolean
- .aiActions([local]) ⇒
Array.<IntentAction>
- .aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒
Array.<QuickReplyDisambiguation>
- .hasAiActionsForDisambiguation(minimum, [local]) ⇒
boolean
- .intent(getDataOrScore) ⇒
null
|string
|Intent
- .entity(name, [sequence]) ⇒
number
|string
|null
- .isAttachment() ⇒
boolean
- .isSetContext(varsToCheck)
- .getSetContext([includeContextSync]) ⇒
object
- .isImage([attachmentIndex], [includingStickers]) ⇒
boolean
- .isFile([attachmentIndex]) ⇒
boolean
- .hasLocation() ⇒
boolean
- .getLocation() ⇒
null
|Object
- .attachment([attachmentIndex]) ⇒
object
|null
- .attachmentUrl([attachmentIndex]) ⇒
string
|null
- .isMessage() ⇒
boolean
- .isQuickReply() ⇒
boolean
- .isText() ⇒
boolean
- .isSticker([includeToTextStickers]) ⇒
boolean
- .text([tokenized]) ⇒
string
- .textAlternatives() ⇒
Array.<TextAlternative>
- .expected() ⇒
Action
|null
- .expectedKeywords([justOnce])
- .expectedContext([justOnce], [includeKeywords]) ⇒
object
- .quickReply([getData]) ⇒
null
|string
|object
- .isPostBack() ⇒
boolean
- .isReferral() ⇒
boolean
- .isOptin() ⇒
boolean
- .setAction(action, [data]) ⇒
Action
|null
|undefined
- .action([getData]) ⇒
null
|string
- .actionData() ⇒
object
- .getSetState(keysFromAi) ⇒
object
- .isConfidentInput() ⇒
boolean
- .actionByAi() ⇒
string
|null
- .aiActionsWinner() ⇒
IntentAction
|null
- .postBack([getData]) ⇒
null
|string
|object
- .expectedEntities() ⇒
Array.<string>
new Request()
Instance of {Request} class is passed as first parameter of handler (req)
new Request(event, state, pageId, globalIntents, [orchestratorOptions], [configuration])
Param | Type |
---|---|
event | * |
state | S |
pageId | string |
globalIntents | Map |
[orchestratorOptions] | RequestOrchestratorOptions |
[configuration] | C |
request.params
Kind: instance property of Request
Properties
Name | Type | Description |
---|---|---|
params | object | plugin configuration |
Array.<Attachment>
request.attachments : Kind: instance property of Request
number
| null
request.timestamp : timestamp
Kind: instance property of Request
string
request.senderId : senderId sender.id from the event
Kind: instance property of Request
string
request.recipientId : recipientId recipient.id from the event
Kind: instance property of Request
string
request.pageId : pageId page identifier from the event
Kind: instance property of Request
S
request.state : current state of the conversation
Kind: instance property of Request
Array.<string>
request.features : features supported messaging features
Kind: instance property of Request
Array.<string>
request.subscribtions : state list of subscribed tags
Kind: instance property of Request
Array.<Entity>
request.entities : entities list of entities
Kind: instance property of Request
Array.<Intent>
request.intents : intents list of resolved intents
Kind: instance property of Request
OrchestratorClientOptions
request._orchestratorClientOptions : Kind: instance property of Request
C
request.configuration : Kind: instance property of Request
object
request.event : The original messaging event
Kind: instance property of Request
enum
request.AI_SETSTATE : Kind: instance enum of Request
Properties
Name | Type | Default |
---|---|---|
ONLY | AiSetStateOption | 1 |
INCLUDE | AiSetStateOption | 0 |
EXCLUDE | AiSetStateOption | -1 |
EXCLUDE_WITH_SET_ENTITIES | AiSetStateOption | -2 |
EXCLUDE_WITHOUT_SET_ENTITIES | AiSetStateOption | -3 |
boolean
request.supportsFeature(feature) ⇒ Returns true if a channel supports specified feature
Kind: instance method of Request
Param | Type |
---|---|
feature | string |
boolean
request.isStandby() ⇒ Returns true, if the incoming event is standby
Kind: instance method of Request
Array.<IntentAction>
request.aiActions([local]) ⇒ Get all matched actions from NLP intents
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[local] | boolean | false |
Array.<QuickReplyDisambiguation>
request.aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒ Covert all matched actions for disambiguation purposes
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[limit] | number | 5 |
[aiActions] | Array.<IntentAction> |
|
[overrideAction] | string | null |
boolean
request.hasAiActionsForDisambiguation(minimum, [local]) ⇒ Returns true, if there is an action for disambiguation
Kind: instance method of Request
Param | Type | Default |
---|---|---|
minimum | number | 1 |
[local] | boolean | false |
null
| string
| Intent
request.intent(getDataOrScore) ⇒ Returns intent, when using AI
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
getDataOrScore | boolean | number | false | score limit or true for getting intent data |
number
| string
| null
request.entity(name, [sequence]) ⇒ Get matched entity value
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
name | string | name of requested entity | |
[sequence] | number | 0 | when there are more then one entity |
boolean
request.isAttachment() ⇒ Checks, when message contains an attachment (file, image or location)
Kind: instance method of Request
request.isSetContext(varsToCheck)
Orchestrator: check, if the request updates only $context variables
- when no variables to check provided,
returns false when
set_context
is bundled within another conversational event
Kind: instance method of Request
Param | Type | Description |
---|---|---|
varsToCheck | Array.<string> | list of variables to check |
object
request.getSetContext([includeContextSync]) ⇒ Orchestrator: get current thread context update
Kind: instance method of Request
Returns: object
- - with §
prefixed keys
Param | Type | Default |
---|---|---|
[includeContextSync] | boolean | false |
boolean
request.isImage([attachmentIndex], [includingStickers]) ⇒ Checks, when the attachment is an image, but not a sticker
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
[includingStickers] | boolean | false | return true, when the image is also a sticker |
boolean
request.isFile([attachmentIndex]) ⇒ Checks, when the attachment is a file
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
boolean
request.hasLocation() ⇒ Checks for location in attachments
Kind: instance method of Request
null
| Object
request.getLocation() ⇒ Gets location coordinates from attachment, when exists
Kind: instance method of Request
Example
const { Router } = require('wingbot');const bot = new Router();bot.use('start', (req, res) => {res.text('share location?', [// location share quick reply{ action: 'locAction', title: 'Share location', isLocation: true }]);});bot.use('locAction', (req, res) => {if (req.hasLocation()) {const { lat, long } = req.getLocation();res.text(`Got ${lat}, ${long}`);} else {res.text('No location received');}});
object
| null
request.attachment([attachmentIndex]) ⇒ Returns whole attachment or null
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
string
| null
request.attachmentUrl([attachmentIndex]) ⇒ Returns attachment URL
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
boolean
request.isMessage() ⇒ Returns true, when the request is text message, quick reply or attachment
Kind: instance method of Request
boolean
request.isQuickReply() ⇒ Check, that message is a quick reply
Kind: instance method of Request
boolean
request.isText() ⇒ Check, that message is PURE text
Kind: instance method of Request
boolean
request.isSticker([includeToTextStickers]) ⇒ Returns true, when the attachment is a sticker
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[includeToTextStickers] | boolean | false | including strickers transformed into a text |
string
request.text([tokenized]) ⇒ Returns text of the message
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[tokenized] | boolean | false | when true, message is normalized to lowercase with - |
Example
console.log(req.text(true)) // "can-you-help-me"
Array.<TextAlternative>
request.textAlternatives() ⇒ Returns all text message alternatives including it's score
Kind: instance method of Request
Action
| null
request.expected() ⇒ Returns the request expected handler in case have been set last response
Kind: instance method of Request
request.expectedKeywords([justOnce])
Returns all expected keywords for the next request (just expected keywords)
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[justOnce] | boolean | false | - don't return already retained items |
Example
bot.use('my-route', (req, res) => {res.setState(req.expectedKeywords());});
object
request.expectedContext([justOnce], [includeKeywords]) ⇒ Returns current turn-around context (expected and expected keywords)
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[justOnce] | boolean | false | don't return already retained items |
[includeKeywords] | boolean | false | keep intents from quick replies |
Example
bot.use('my-route', (req, res) => {res.setState(req.expectedContext());});