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 |
request.attachments : Array.<Attachment>
Kind: instance property of Request
request.timestamp : number | null
timestamp
Kind: instance property of Request
request.senderId : string
senderId sender.id from the event
Kind: instance property of Request
request.recipientId : string
recipientId recipient.id from the event
Kind: instance property of Request
request.pageId : string
pageId page identifier from the event
Kind: instance property of Request
request.state : S
current state of the conversation
Kind: instance property of Request
request.features : Array.<string>
features supported messaging features
Kind: instance property of Request
request.subscribtions : Array.<string>
state list of subscribed tags
Kind: instance property of Request
request.entities : Array.<Entity>
entities list of entities
Kind: instance property of Request
request.intents : Array.<Intent>
intents list of resolved intents
Kind: instance property of Request
request._orchestratorClientOptions : OrchestratorClientOptions
Kind: instance property of Request
request.configuration : C
Kind: instance property of Request
request.event : object
The original messaging event
Kind: instance property of Request
request.AI_SETSTATE : enum
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 |
request.supportsFeature(feature) ⇒ boolean
Returns true if a channel supports specified feature
Kind: instance method of Request
| Param | Type |
|---|---|
| feature | string |
request.isStandby() ⇒ boolean
Returns true, if the incoming event is standby
Kind: instance method of Request
request.aiActions([local]) ⇒ Array.<IntentAction>
Get all matched actions from NLP intents
Kind: instance method of Request
| Param | Type | Default |
|---|---|---|
| [local] | boolean | false |
request.aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒ Array.<QuickReplyDisambiguation>
Covert all matched actions for disambiguation purposes
Kind: instance method of Request
| Param | Type | Default |
|---|---|---|
| [limit] | number | 5 |
| [aiActions] | Array.<IntentAction> | |
| [overrideAction] | string | null |
request.hasAiActionsForDisambiguation(minimum, [local]) ⇒ boolean
Returns true, if there is an action for disambiguation
Kind: instance method of Request
| Param | Type | Default |
|---|---|---|
| minimum | number | 1 |
| [local] | boolean | false |
request.intent(getDataOrScore) ⇒ null | string | Intent
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 |
request.entity(name, [sequence]) ⇒ number | string | null
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 |
request.isAttachment() ⇒ boolean
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_contextis bundled within another conversational event
Kind: instance method of Request
| Param | Type | Description |
|---|---|---|
| varsToCheck | Array.<string> | list of variables to check |
request.getSetContext([includeContextSync]) ⇒ object
Orchestrator: get current thread context update
Kind: instance method of Request
Returns: object - - with § prefixed keys
| Param | Type | Default |
|---|---|---|
| [includeContextSync] | boolean | false |
request.isImage([attachmentIndex], [includingStickers]) ⇒ boolean
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 |
request.isFile([attachmentIndex]) ⇒ boolean
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 |
request.hasLocation() ⇒ boolean
Checks for location in attachments
Kind: instance method of Request
request.getLocation() ⇒ null | Object
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');}});
request.attachment([attachmentIndex]) ⇒ object | null
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 |
request.attachmentUrl([attachmentIndex]) ⇒ string | null
Returns attachment URL
Kind: instance method of Request
| Param | Type | Default | Description |
|---|---|---|---|
| [attachmentIndex] | number | 0 | use, when user sends more then one attachment |
request.isMessage() ⇒ boolean
Returns true, when the request is text message, quick reply or attachment
Kind: instance method of Request
request.isQuickReply() ⇒ boolean
Check, that message is a quick reply
Kind: instance method of Request
request.isText() ⇒ boolean
Check, that message is PURE text
Kind: instance method of Request
request.isSticker([includeToTextStickers]) ⇒ boolean
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 |
request.text([tokenized]) ⇒ string
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"
request.textAlternatives() ⇒ Array.<TextAlternative>
Returns all text message alternatives including it's score
Kind: instance method of Request
request.expected() ⇒ Action | null
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());});
request.expectedContext([justOnce], [includeKeywords]) ⇒ object
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());});